diff --git a/Examples/MAX32655/Demo_2048/ARM/inc/cfs_logo.h b/Examples/MAX32655/Demo_2048/ARM/inc/cfs_logo.h index 6687fa6158..1277d89c56 100644 --- a/Examples/MAX32655/Demo_2048/ARM/inc/cfs_logo.h +++ b/Examples/MAX32655/Demo_2048/ARM/inc/cfs_logo.h @@ -16,6 +16,9 @@ * ******************************************************************************/ +#ifndef EXAMPLES_MAX32655_DEMO_2048_ARM_INC_CFS_LOGO_H_ +#define EXAMPLES_MAX32655_DEMO_2048_ARM_INC_CFS_LOGO_H_ + // clang-format off /* **** Includes **** */ @@ -115,3 +118,5 @@ __flash uint16_t cfs_logo[] = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; + +#endif // EXAMPLES_MAX32655_DEMO_2048_ARM_INC_CFS_LOGO_H_ diff --git a/Examples/MAX32655/Demo_2048/ARM/inc/clear_sans_bold_game_text.h b/Examples/MAX32655/Demo_2048/ARM/inc/clear_sans_bold_game_text.h index 08cad6f579..d4a5f0f692 100644 --- a/Examples/MAX32655/Demo_2048/ARM/inc/clear_sans_bold_game_text.h +++ b/Examples/MAX32655/Demo_2048/ARM/inc/clear_sans_bold_game_text.h @@ -16,6 +16,9 @@ * ******************************************************************************/ +#ifndef EXAMPLES_MAX32655_DEMO_2048_ARM_INC_CLEAR_SANS_BOLD_GAME_TEXT_H_ +#define EXAMPLES_MAX32655_DEMO_2048_ARM_INC_CLEAR_SANS_BOLD_GAME_TEXT_H_ + // clang-format off /* **** Includes **** */ @@ -311,3 +314,5 @@ __flash uint16_t game_text_moves[] = { 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000 }; + +#endif // EXAMPLES_MAX32655_DEMO_2048_ARM_INC_CLEAR_SANS_BOLD_GAME_TEXT_H_ diff --git a/Examples/MAX32655/Demo_2048/ARM/inc/clear_sans_bold_scaled_block_digits.h b/Examples/MAX32655/Demo_2048/ARM/inc/clear_sans_bold_scaled_block_digits.h index feab124606..f074e776ee 100644 --- a/Examples/MAX32655/Demo_2048/ARM/inc/clear_sans_bold_scaled_block_digits.h +++ b/Examples/MAX32655/Demo_2048/ARM/inc/clear_sans_bold_scaled_block_digits.h @@ -16,6 +16,9 @@ * ******************************************************************************/ +#ifndef EXAMPLES_MAX32655_DEMO_2048_ARM_INC_CLEAR_SANS_BOLD_SCALED_BLOCK_DIGITS_H_ +#define EXAMPLES_MAX32655_DEMO_2048_ARM_INC_CLEAR_SANS_BOLD_SCALED_BLOCK_DIGITS_H_ + // clang-format off /* **** Includes **** */ @@ -356,3 +359,5 @@ __flash uint16_t block_2048[] = { : (block) == 1024 ? block_1024 \ : (block) == 2048 ? block_2048 \ : NULL) + +#endif // EXAMPLES_MAX32655_DEMO_2048_ARM_INC_CLEAR_SANS_BOLD_SCALED_BLOCK_DIGITS_H_ diff --git a/Examples/MAX32655/Demo_2048/ARM/inc/end_game_text.h b/Examples/MAX32655/Demo_2048/ARM/inc/end_game_text.h index ae26bd1ec4..577fc34df1 100644 --- a/Examples/MAX32655/Demo_2048/ARM/inc/end_game_text.h +++ b/Examples/MAX32655/Demo_2048/ARM/inc/end_game_text.h @@ -16,6 +16,9 @@ * ******************************************************************************/ +#ifndef EXAMPLES_MAX32655_DEMO_2048_ARM_INC_END_GAME_TEXT_H_ +#define EXAMPLES_MAX32655_DEMO_2048_ARM_INC_END_GAME_TEXT_H_ + // clang-format off /* **** Includes **** */ @@ -293,3 +296,5 @@ __flash uint16_t game_over[] = { 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703, 0x1703 }; + +#endif // EXAMPLES_MAX32655_DEMO_2048_ARM_INC_END_GAME_TEXT_H_ diff --git a/Examples/MAX32655/Demo_2048/ARM/inc/graphics.h b/Examples/MAX32655/Demo_2048/ARM/inc/graphics.h index e948a6aecd..36db538a4a 100644 --- a/Examples/MAX32655/Demo_2048/ARM/inc/graphics.h +++ b/Examples/MAX32655/Demo_2048/ARM/inc/graphics.h @@ -16,6 +16,9 @@ * ******************************************************************************/ +#ifndef EXAMPLES_MAX32655_DEMO_2048_ARM_INC_GRAPHICS_H_ +#define EXAMPLES_MAX32655_DEMO_2048_ARM_INC_GRAPHICS_H_ + /* **** Includes **** */ #include @@ -258,3 +261,5 @@ void Graphics_DisplayGameOver(void); * @brief Draws the "you win" box popup when game is finished. */ void Graphics_DisplayYouWin(void); + +#endif // EXAMPLES_MAX32655_DEMO_2048_ARM_INC_GRAPHICS_H_ diff --git a/Examples/MAX32655/Demo_2048/ARM/inc/ipc_defines.h b/Examples/MAX32655/Demo_2048/ARM/inc/ipc_defines.h new file mode 100644 index 0000000000..69e7ed870c --- /dev/null +++ b/Examples/MAX32655/Demo_2048/ARM/inc/ipc_defines.h @@ -0,0 +1,60 @@ +/****************************************************************************** + * + * Copyright (C) 2024 Analog Devices, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +#ifndef EXAMPLES_MAX32655_DEMO_2048_ARM_INC_IPC_DEFINES_H_ +#define EXAMPLES_MAX32655_DEMO_2048_ARM_INC_IPC_DEFINES_H_ + +/* **** Includes **** */ + +#include + +/* **** Definitions **** */ + +// These should match with the RISC-V core's copy of ipc_defines.h + +/// Semaphores +// Should never reach here +#if (MAILBOX_SIZE == 0) +#error "Mailbox size is 0." +#endif + +// Keep track for Semaphore peripheral. +#define SEMA_IDX_ARM (0) +#define SEMA_IDX_RISCV (1) + +#define MAILBOX_OVERHEAD (2 * sizeof(uint16_t)) +#define MAILBOX_PAYLOAD_LEN (MAILBOX_SIZE - MAILBOX_OVERHEAD) +typedef struct { + uint16_t readLocation; + uint16_t writeLocation; +#if (MAILBOX_SIZE == 0) + uint8_t payload[1]; +#else + uint8_t payload[MAILBOX_PAYLOAD_LEN]; +#endif +} mxcSemaBox_t; + +#define MAILBOX_MAIN_GRID_IDX (0) // Main grid indexes are from 0 to (16 blocks * 4 bytes) - 1. +#define MAILBOX_MAIN_GRID_STATE_IDX (4 * 16) // Indexes are from (4 bytes * 16) to ((4 bytes * 16) + (1 byte * 16))) +#define MAILBOX_KEYPRESS_IDX ((4 * 16) + (1 * 16)) // All indexes before are for the main grids. +#define MAILBOX_IF_BLOCK_MOVED_IDX (MAILBOX_KEYPRESS_IDX + 1) +#define MAILBOX_NEW_BLOCK_LOCATION_IDX (MAILBOX_IF_BLOCK_MOVED_IDX + 1) +#define MAILBOX_GAME_STATE_IDX (MAILBOX_NEW_BLOCK_LOCATION_IDX + 1) +#define MAILBOX_MOVES_COUNT_IDX (MAILBOX_GAME_STATE_IDX + 1) + +#endif // EXAMPLES_MAX32655_DEMO_2048_ARM_INC_IPC_DEFINES_H_ diff --git a/Examples/MAX32655/Demo_2048/ARM/main.c b/Examples/MAX32655/Demo_2048/ARM/main.c index 30f2163da7..2380ced755 100644 --- a/Examples/MAX32655/Demo_2048/ARM/main.c +++ b/Examples/MAX32655/Demo_2048/ARM/main.c @@ -38,6 +38,7 @@ // Application Libraries #include "graphics.h" +#include "ipc_defines.h" /* **** Definitions **** */ @@ -52,36 +53,6 @@ // for the RISC-V as they share the same port. #define RISCV_CONTROLLER_BAUD (115200) -/// Semaphores -// Should never reach here -#if (MAILBOX_SIZE == 0) -#error "Mailbox size is 0." -#endif - -// Keep track for Semaphore peripheral. -#define SEMA_IDX_ARM (0) -#define SEMA_IDX_RISCV (1) - -#define MAILBOX_OVERHEAD (2 * sizeof(uint16_t)) -#define MAILBOX_PAYLOAD_LEN (MAILBOX_SIZE - MAILBOX_OVERHEAD) -typedef struct { - uint16_t readLocation; - uint16_t writeLocation; -#if (MAILBOX_SIZE == 0) - uint8_t payload[1]; -#else - uint8_t payload[MAILBOX_PAYLOAD_LEN]; -#endif -} mxcSemaBox_t; - -#define MAILBOX_MAIN_GRID_IDX (0) // Main grid indexes are from 0 to (16 blocks * 4 bytes) - 1. -#define MAILBOX_MAIN_GRID_STATE_IDX (4 * 16) // Indexes are from (4 bytes * 16) to ((4 bytes * 16) + (1 byte * 16))) -#define MAILBOX_KEYPRESS_IDX ((4 * 16) + (1 * 16)) // All indexes before are for the main grids. -#define MAILBOX_IF_BLOCK_MOVED_IDX (MAILBOX_KEYPRESS_IDX + 1) -#define MAILBOX_NEW_BLOCK_LOCATION_IDX (MAILBOX_IF_BLOCK_MOVED_IDX + 1) -#define MAILBOX_GAME_STATE_IDX (MAILBOX_NEW_BLOCK_LOCATION_IDX + 1) -#define MAILBOX_MOVES_COUNT_IDX (MAILBOX_GAME_STATE_IDX + 1) - /* **** Globals **** */ // Defined in sema_reva.c extern mxcSemaBox_t *mxcSemaBox0; // ARM writes, RISCV reads @@ -133,19 +104,19 @@ graphics_slide_direction_t ReceiveDirectionFromRISCVCore(void) // UP case 'w': return GRAPHICS_SLIDE_DIR_UP; - + // DOWN case 's': return GRAPHICS_SLIDE_DIR_DOWN; - + // LEFT case 'a': return GRAPHICS_SLIDE_DIR_LEFT; - + // RIGHT case 'd': return GRAPHICS_SLIDE_DIR_RIGHT; - + default: return -1; } @@ -198,7 +169,7 @@ int main(void) if (error != E_NO_ERROR) { PRINT("ARM: Error speeding up baud rate: %d\n", error); LED_On(LED_RED); - while(1); + while (1) {} } PRINT("\n\n*******************************************************************************\n"); @@ -220,14 +191,14 @@ int main(void) if (error != E_NO_ERROR) { PRINT("ARM: Semaphore for ARM core is busy: %d\n", error); LED_On(LED_RED); - while(1); + while (1) {} } error = MXC_SEMA_GetSema(SEMA_IDX_ARM); if (error != E_NO_ERROR) { PRINT("ARM: Semaphore is busy - with previous value: %d\n\n", MXC_SEMA->semaphores[SEMA_IDX_ARM]); LED_On(LED_RED); - while(1); + while (1) {} } else { PRINT("ARM: Semaphore is not busy - with previous value: %d\n\n", MXC_SEMA->semaphores[SEMA_IDX_ARM]); } @@ -254,14 +225,14 @@ int main(void) if (MXC_RTC_Init(0, 0) != E_NO_ERROR) { PRINT("ARM: Error initializing RTC: %d\n", error); LED_On(LED_RED); - while(1); + while (1) {} } error = Graphics_Init(); if (error != E_NO_ERROR) { PRINT("ARM: Error initializing graphics: %d\n", error); LED_On(LED_RED); - while(1); + while (1) {} } // Wait for Game logic to finish initializing on RISCV. @@ -277,7 +248,7 @@ int main(void) if (game_state != IN_PROGRESS) { PRINT("ARM: Error starting game.\n"); LED_On(LED_RED); - while(1); + while (1) {} } Graphics_AddNewBlock(new_block_row, new_block_col, ARM_GRID_COPY[new_block_row][new_block_col]); @@ -289,7 +260,7 @@ int main(void) if (MXC_RTC_Start() != E_NO_ERROR) { PRINT("ARM: Error starting timer: %d\n", error); LED_On(LED_RED); - while(1); + while (1) {} } uint32_t prev_seconds = 0; @@ -360,7 +331,7 @@ int main(void) MXC_Delay(MXC_DELAY_MSEC(750)); Graphics_DisplayYouWin(); - while(1); + while (1) {} } else if (game_state == GAME_OVER) { PRINT("ARM: Game Over. Nice try! Better luck next time.\n"); PRINT("ARM: Ending game.\n"); @@ -369,7 +340,7 @@ int main(void) MXC_Delay(MXC_DELAY_MSEC(750)); Graphics_DisplayGameOver(); - while(1); + while (1) {} } // Signal RISC-V Core that it's ready for the next grid state. diff --git a/Examples/MAX32655/Demo_2048/ARM/resources/all_imgs.c b/Examples/MAX32655/Demo_2048/ARM/resources/all_imgs.c index afa363ed54..1536bb8537 100644 --- a/Examples/MAX32655/Demo_2048/ARM/resources/all_imgs.c +++ b/Examples/MAX32655/Demo_2048/ARM/resources/all_imgs.c @@ -1,40 +1,20 @@ - -/******************************************************************************* -* Copyright (C) 2022 Maxim Integrated Products, Inc., All rights Reserved. -* -* This software is protected by copyright laws of the United States and -* of foreign countries. This material may also be protected by patent laws -* and technology transfer regulations of the United States and of foreign -* countries. This software is furnished under a license agreement and/or a -* nondisclosure agreement and may only be used or reproduced in accordance -* with the terms of those agreements. Dissemination of this information to -* any party or parties not specified in the license agreement and/or -* nondisclosure agreement is expressly prohibited. -* -* The above copyright notice and this permission notice shall be included -* in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES -* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -* -* Except as contained in this notice, the name of Maxim Integrated -* Products, Inc. shall not be used except as stated in the Maxim Integrated -* Products, Inc. Branding Policy. -* -* The mere transfer of this software does not imply any licenses -* of trade secrets, proprietary technology, copyrights, patents, -* trademarks, maskwork rights, or any other form of intellectual -* property whatsoever. Maxim Integrated Products, Inc. retains all -* ownership rights. -******************************************************************************* -*/ - - +/****************************************************************************** + * + * Copyright (C) 2024 Analog Devices, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ __attribute__ ((section(".bin_storage_img"))) __attribute__ ((__used__)) const unsigned char imgs_arr[ ] = { diff --git a/Examples/MAX32655/Demo_2048/ARM/resources/bitmap.h b/Examples/MAX32655/Demo_2048/ARM/resources/bitmap.h index e154825b3b..705e43b76f 100644 --- a/Examples/MAX32655/Demo_2048/ARM/resources/bitmap.h +++ b/Examples/MAX32655/Demo_2048/ARM/resources/bitmap.h @@ -1,42 +1,24 @@ +/****************************************************************************** + * + * Copyright (C) 2024 Analog Devices, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ -/******************************************************************************* -* Copyright (C) 2022 Maxim Integrated Products, Inc., All rights Reserved. -* -* This software is protected by copyright laws of the United States and -* of foreign countries. This material may also be protected by patent laws -* and technology transfer regulations of the United States and of foreign -* countries. This software is furnished under a license agreement and/or a -* nondisclosure agreement and may only be used or reproduced in accordance -* with the terms of those agreements. Dissemination of this information to -* any party or parties not specified in the license agreement and/or -* nondisclosure agreement is expressly prohibited. -* -* The above copyright notice and this permission notice shall be included -* in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES -* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -* -* Except as contained in this notice, the name of Maxim Integrated -* Products, Inc. shall not be used except as stated in the Maxim Integrated -* Products, Inc. Branding Policy. -* -* The mere transfer of this software does not imply any licenses -* of trade secrets, proprietary technology, copyrights, patents, -* trademarks, maskwork rights, or any other form of intellectual -* property whatsoever. Maxim Integrated Products, Inc. retains all -* ownership rights. -******************************************************************************* -*/ - -#ifndef _BITMAP_H_ -#define _BITMAP_H_ +#ifndef EXAMPLES_MAX32655_DEMO_2048_ARM_RESOURCES_BITMAP_H_ +#define EXAMPLES_MAX32655_DEMO_2048_ARM_RESOURCES_BITMAP_H_ // bitmaps id @@ -47,4 +29,4 @@ #define urw_gothic_13_white_bg_grey 3 -#endif //_BITMAP_H_ +#endif // EXAMPLES_MAX32655_DEMO_2048_ARM_RESOURCES_BITMAP_H_ diff --git a/Examples/MAX32655/Demo_2048/ARM/src/graphics.c b/Examples/MAX32655/Demo_2048/ARM/src/graphics.c index 426bbf5acd..04137c4c0e 100644 --- a/Examples/MAX32655/Demo_2048/ARM/src/graphics.c +++ b/Examples/MAX32655/Demo_2048/ARM/src/graphics.c @@ -103,7 +103,7 @@ int Graphics_Init(void) MXC_TFT_DrawBitmapInvertedMask(TIME_DIGIT3_OFFSET_X(GAME_TEXT_DIGIT_WIDTH(0)), TIME_OFFSET_Y, GAME_TEXT_DIGIT_WIDTH(0), GAME_TEXT_DIGITS_HEIGHT, GAME_TEXT_DIGIT_PTR(0), RGB565_BLACK, RGB565_WHITE); // Draw grid. - MXC_TFT_DrawRoundedRect(GRID_OFFSET_X + GRID_SPACING, GRID_OFFSET_Y + GRID_SPACING, GRID_LENGTH, GRID_LENGTH, F_GRID_COLOR, RADIUS_FOR_CORNERS, F_BACKGROUND_COLOR); + MXC_TFT_DrawRect(GRID_OFFSET_X + GRID_SPACING, GRID_OFFSET_Y + GRID_SPACING, GRID_LENGTH, GRID_LENGTH, F_GRID_COLOR); for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { // Focusing on top left corner of the top left block in the grid to help with visualizing the coordinates and calculations. @@ -127,7 +127,7 @@ void Graphics_AddNewBlock(int row, int col, int block_2_4) // Increase the block size by 10 pixels MXC_TFT_DrawRoundedRect(x, y, ((frame_i * 10) > BLOCK_LENGTH) ? BLOCK_LENGTH : ((frame_i * 10) + 1), ((frame_i * 10) > BLOCK_LENGTH) ? BLOCK_LENGTH : ((frame_i * 10) + 1), FORMAT_RGB565_TO_PACKET(RGB_BLOCK_COLOR(block_2_4)), RADIUS_FOR_CORNERS, ((frame_i * 10) > BLOCK_LENGTH) ? F_EMPTY_BLOCK_COLOR : F_GRID_COLOR); - + // Don't delay when empty space is fully filled. if (frame_i < 5) { // Minimum speed visual for human eye while also being fast and not laggy. @@ -223,7 +223,7 @@ inline void Graphics_AddBlock(int row, int col, int value) // 0x0000 is RGB color BLACK (background of digit) which will be masked out to match color of block. MXC_TFT_DrawBitmapMask(dx, dy, BLOCK_DIGIT_PX_WIDTH(value), BLOCK_DIGIT_PX_HEIGHT(value), block_128, RGB565_BLACK, RGB565_BLOCK_128); break; - + case 256: // Draw block. MXC_TFT_DrawRoundedRect(x, y, BLOCK_LENGTH, BLOCK_LENGTH, FORMAT_RGB565_TO_PACKET(RGB565_BLOCK_256), RADIUS_FOR_CORNERS, F_GRID_COLOR); @@ -232,7 +232,7 @@ inline void Graphics_AddBlock(int row, int col, int value) // 0x0000 is RGB color BLACK (background of digit) which will be masked out to match color of block. MXC_TFT_DrawBitmapMask(dx, dy, BLOCK_DIGIT_PX_WIDTH(value), BLOCK_DIGIT_PX_HEIGHT(value), block_256, RGB565_BLACK, RGB565_BLOCK_256); break; - + case 512: // Draw block. MXC_TFT_DrawRoundedRect(x, y, BLOCK_LENGTH, BLOCK_LENGTH, FORMAT_RGB565_TO_PACKET(RGB565_BLOCK_512), RADIUS_FOR_CORNERS, F_GRID_COLOR); @@ -241,7 +241,7 @@ inline void Graphics_AddBlock(int row, int col, int value) // 0x0000 is RGB color BLACK (background of digit) which will be masked out to match color of block. MXC_TFT_DrawBitmapMask(dx, dy, BLOCK_DIGIT_PX_WIDTH(value), BLOCK_DIGIT_PX_HEIGHT(value), block_512, RGB565_BLACK, RGB565_BLOCK_512); break; - + case 1024: // Draw block. MXC_TFT_DrawRoundedRect(x, y, BLOCK_LENGTH, BLOCK_LENGTH, FORMAT_RGB565_TO_PACKET(RGB565_BLOCK_1024), RADIUS_FOR_CORNERS, F_GRID_COLOR); @@ -250,7 +250,7 @@ inline void Graphics_AddBlock(int row, int col, int value) // 0x0000 is RGB color BLACK (background of digit) which will be masked out to match color of block. MXC_TFT_DrawBitmapMask(dx, dy, BLOCK_DIGIT_PX_WIDTH(value), BLOCK_DIGIT_PX_HEIGHT(value), block_1024, RGB565_BLACK, RGB565_BLOCK_1024); break; - + case 2048: // Draw block. MXC_TFT_DrawRoundedRect(x, y, BLOCK_LENGTH, BLOCK_LENGTH, FORMAT_RGB565_TO_PACKET(RGB565_BLOCK_2048), RADIUS_FOR_CORNERS, F_GRID_COLOR); @@ -273,7 +273,7 @@ void Graphics_CombineSingleBlock(int row, int col, int new_value) MXC_TFT_DrawRoundedRect(x, y, BLOCK_LENGTH, BLOCK_LENGTH, FORMAT_RGB565_TO_PACKET(new_value), RADIUS_FOR_CORNERS, F_GRID_COLOR); // Animate the blow up. - // 4 is the amount of pixels between each block. That's the extent that the block will temporarily expand. + // 4 is the amount of pixels between each block. That's the extent that the block will temporarily expand. for (int i = 0; i < BLOCK_SPACING + 1; i++) { MXC_TFT_DrawRoundedRect(x - i, y - i, BLOCK_LENGTH + (2*i), BLOCK_LENGTH + (2*i), FORMATTED_RGB_BLOCK_COLOR(new_value), RADIUS_FOR_CORNERS, F_GRID_COLOR); @@ -309,7 +309,7 @@ void Graphics_CombineSingleBlock(int row, int col, int new_value) // @param frame_i Current frame of the animation. // @param current_length Length of block at current frame. // @param f_color Formatted color code of outer border. -// @param radius Radius ofrounded cornewrs and width of block. +// @param radius Radius ofrounded cornewrs and width of block. static void graphics_helper_CombineBlocks(uint32_t x, uint32_t y, int frame_i, uint32_t current_length, uint32_t f_color, uint32_t radius) { // Draw top horizontal lines. @@ -391,7 +391,7 @@ static void graphics_helper_CombineBlocks(uint32_t x, uint32_t y, int frame_i, u // @param frame_i Current frame of the animation. // @param current_length Length of block at current frame. // @param f_color Formatted color code of outer border. -// @param radius Radius ofrounded cornewrs and width of block. +// @param radius Radius ofrounded cornewrs and width of block. static void graphics_helper_eraseCorners(uint32_t x, uint32_t y, int frame_i, uint32_t current_length, uint32_t f_color, uint32_t radius) { for (int p_y = 0; p_y < BLOCK_LENGTH; p_y++) { @@ -440,7 +440,7 @@ void Graphics_CombineBlocks(uint32_t grid[4][4], block_state_t grid_state[4][4]) MXC_TFT_DrawRoundedRect(x, y, BLOCK_LENGTH, BLOCK_LENGTH, FORMATTED_RGB_BLOCK_COLOR(grid[row][col]), RADIUS_FOR_CORNERS, F_GRID_COLOR); } else { graphics_helper_CombineBlocks(x, y, frame_i, BLOCK_LENGTH + (2 * frame_i), FORMATTED_RGB_BLOCK_COLOR(grid[row][col]), RADIUS_FOR_CORNERS); - } + } } } } @@ -535,7 +535,7 @@ void Graphics_EraseBlocks(block_state_t grid_state[4][4], graphics_slide_directi } MXC_TFT_DrawHorizontalLine(x + RADIUS_FOR_CORNERS - dx, y + p_y, BLOCK_LENGTH - (2 * (RADIUS_FOR_CORNERS - dx)), F_EMPTY_BLOCK_COLOR); - + } else { MXC_TFT_DrawHorizontalLine(x, y + p_y, BLOCK_LENGTH, F_EMPTY_BLOCK_COLOR); } @@ -544,7 +544,7 @@ void Graphics_EraseBlocks(block_state_t grid_state[4][4], graphics_slide_directi } } break; - + case GRAPHICS_SLIDE_DIR_DOWN: // Start from top row to bottom row (column order doesn't matter). // This for-loop keeps track of the localized y position of where the horizontal line is drawn. @@ -576,7 +576,7 @@ void Graphics_EraseBlocks(block_state_t grid_state[4][4], graphics_slide_directi } MXC_TFT_DrawHorizontalLine(x + RADIUS_FOR_CORNERS - dx, y + p_y, BLOCK_LENGTH - (2 * (RADIUS_FOR_CORNERS - dx)), F_EMPTY_BLOCK_COLOR); - + } else { MXC_TFT_DrawHorizontalLine(x, y + p_y, BLOCK_LENGTH, F_EMPTY_BLOCK_COLOR); } @@ -585,7 +585,7 @@ void Graphics_EraseBlocks(block_state_t grid_state[4][4], graphics_slide_directi } } break; - + case GRAPHICS_SLIDE_DIR_LEFT: // Start from right column to left column (row order doesn't matter). // This for-loop keeps track of the localized x position of where the vertical line is drawn. @@ -617,7 +617,7 @@ void Graphics_EraseBlocks(block_state_t grid_state[4][4], graphics_slide_directi } MXC_TFT_DrawVerticalLine(x + p_x, y + RADIUS_FOR_CORNERS - dy, BLOCK_LENGTH - (2 * (RADIUS_FOR_CORNERS - dy)), F_EMPTY_BLOCK_COLOR); - + } else { MXC_TFT_DrawVerticalLine(x + p_x, y, BLOCK_LENGTH, F_EMPTY_BLOCK_COLOR); } @@ -626,7 +626,7 @@ void Graphics_EraseBlocks(block_state_t grid_state[4][4], graphics_slide_directi } } break; - + case GRAPHICS_SLIDE_DIR_RIGHT: // Start from left column to right column (row order doesn't matter). // This for-loop keeps track of the localized x position of where the vertical line is drawn. @@ -658,7 +658,7 @@ void Graphics_EraseBlocks(block_state_t grid_state[4][4], graphics_slide_directi } MXC_TFT_DrawVerticalLine(x + p_x, y + RADIUS_FOR_CORNERS - dy, BLOCK_LENGTH - (2 * (RADIUS_FOR_CORNERS - dy)), F_EMPTY_BLOCK_COLOR); - + } else { MXC_TFT_DrawVerticalLine(x + p_x, y, BLOCK_LENGTH, F_EMPTY_BLOCK_COLOR); } @@ -668,7 +668,7 @@ void Graphics_EraseBlocks(block_state_t grid_state[4][4], graphics_slide_directi } break; - + default: return; } @@ -687,7 +687,7 @@ void Graphics_SetTime(uint32_t total_seconds) { // Convert total time to minutes:seconds (mm:ss) int digit0, digit1, digit2, digit3; - + // The max possible seconds is 5999, which yields 99m:59s. if (total_seconds >= 5999) { digit0 = 9; @@ -703,7 +703,7 @@ void Graphics_SetTime(uint32_t total_seconds) } // Update timer on display. - MXC_TFT_DrawRect(TIME_DIGIT0_OFFSET_X(TIME_DIGIT_WIDTH), TIME_OFFSET_Y, TIME_DIGIT_WIDTH, GAME_TEXT_DIGITS_HEIGHT, F_BACKGROUND_COLOR); + MXC_TFT_DrawRect(TIME_DIGIT0_OFFSET_X(TIME_DIGIT_WIDTH), TIME_OFFSET_Y, TIME_DIGIT_WIDTH, GAME_TEXT_DIGITS_HEIGHT, F_BACKGROUND_COLOR); MXC_TFT_DrawBitmapInvertedMask(TIME_DIGIT0_OFFSET_X(GAME_TEXT_DIGIT_WIDTH(digit0)), TIME_OFFSET_Y, GAME_TEXT_DIGIT_WIDTH(digit0), GAME_TEXT_DIGITS_HEIGHT, GAME_TEXT_DIGIT_PTR(digit0), RGB565_BLACK, RGB565_WHITE); // Don't waste time on re-writing the same digits. @@ -733,7 +733,7 @@ void Graphics_UpdateMovesCount(uint32_t moves_count) { // Convert total time to minutes:seconds (mm:ss) int digit0, digit1, digit2, digit3; - + // The max possible seconds is 5999, which yields 99m:59s. if (moves_count >= 9999) { digit0 = 9; @@ -748,7 +748,7 @@ void Graphics_UpdateMovesCount(uint32_t moves_count) } // Update timer on display. - MXC_TFT_DrawRect(MOVES_DIGIT0_OFFSET_X(MOVES_DIGIT_WIDTH), MOVES_DIGITS_OFFSET_Y, MOVES_DIGIT_WIDTH, GAME_TEXT_DIGITS_HEIGHT, F_BACKGROUND_COLOR); + MXC_TFT_DrawRect(MOVES_DIGIT0_OFFSET_X(MOVES_DIGIT_WIDTH), MOVES_DIGITS_OFFSET_Y, MOVES_DIGIT_WIDTH, GAME_TEXT_DIGITS_HEIGHT, F_BACKGROUND_COLOR); MXC_TFT_DrawBitmapInvertedMask(MOVES_DIGIT0_OFFSET_X(GAME_TEXT_DIGIT_WIDTH(digit0)), MOVES_DIGITS_OFFSET_Y, GAME_TEXT_DIGIT_WIDTH(digit0), GAME_TEXT_DIGITS_HEIGHT, GAME_TEXT_DIGIT_PTR(digit0), RGB565_BLACK, RGB565_WHITE); // Don't waste time on re-writing the same digits. diff --git a/Examples/MAX32655/Demo_2048/RISCV/.vscode/settings.json b/Examples/MAX32655/Demo_2048/RISCV/.vscode/settings.json index bd75836225..8ca5ce8ab8 100644 --- a/Examples/MAX32655/Demo_2048/RISCV/.vscode/settings.json +++ b/Examples/MAX32655/Demo_2048/RISCV/.vscode/settings.json @@ -74,6 +74,9 @@ ], "C_Cpp.default.forcedInclude": [ "${workspaceFolder}/build/project_defines.h" - ] + ], + "files.associations": { + "ipc_defines.h": "c" + } } diff --git a/Examples/MAX32655/Demo_2048/RISCV/inc/controller.h b/Examples/MAX32655/Demo_2048/RISCV/inc/controller.h index 5e7c1930b4..51453a4c21 100644 --- a/Examples/MAX32655/Demo_2048/RISCV/inc/controller.h +++ b/Examples/MAX32655/Demo_2048/RISCV/inc/controller.h @@ -16,6 +16,9 @@ * ******************************************************************************/ +#ifndef EXAMPLES_MAX32655_DEMO_2048_RISCV_INC_CONTROLLER_H_ +#define EXAMPLES_MAX32655_DEMO_2048_RISCV_INC_CONTROLLER_H_ + /* **** Includes **** */ #include @@ -45,3 +48,5 @@ int Controller_Init(mxc_uart_regs_t *uart, uint32_t baud); * @return Success/Fail, see \ref MXC_Error_Codes for a list of return codes. */ int Controller_Start(mxc_uart_req_t *req); + +#endif // EXAMPLES_MAX32655_DEMO_2048_RISCV_INC_CONTROLLER_H_ diff --git a/Examples/MAX32655/Demo_2048/RISCV/inc/game_2048.h b/Examples/MAX32655/Demo_2048/RISCV/inc/game_2048.h index 5c30c22ac2..251f1a8257 100644 --- a/Examples/MAX32655/Demo_2048/RISCV/inc/game_2048.h +++ b/Examples/MAX32655/Demo_2048/RISCV/inc/game_2048.h @@ -16,6 +16,9 @@ * ******************************************************************************/ +#ifndef EXAMPLES_MAX32655_DEMO_2048_RISCV_INC_GAME_2048_H_ +#define EXAMPLES_MAX32655_DEMO_2048_RISCV_INC_GAME_2048_H_ + /* **** Includes **** */ #include @@ -105,3 +108,5 @@ void Game_2048_GetGrid(uint32_t grid[4][4]); * @param grid Pointer to 2-D array to hold the current grid state. */ void Game_2048_GetGridState(uint8_t grid_state[4][4]); + +#endif // EXAMPLES_MAX32655_DEMO_2048_RISCV_INC_GAME_2048_H_ diff --git a/Examples/MAX32655/Demo_2048/RISCV/inc/ipc_defines.h b/Examples/MAX32655/Demo_2048/RISCV/inc/ipc_defines.h index e5fc34e4a5..5127400c7a 100644 --- a/Examples/MAX32655/Demo_2048/RISCV/inc/ipc_defines.h +++ b/Examples/MAX32655/Demo_2048/RISCV/inc/ipc_defines.h @@ -16,10 +16,17 @@ * ******************************************************************************/ +#ifndef EXAMPLES_MAX32655_DEMO_2048_RISCV_INC_IPC_DEFINES_H_ +#define EXAMPLES_MAX32655_DEMO_2048_RISCV_INC_IPC_DEFINES_H_ + /* **** Includes **** */ +#include + /* **** Definitions **** */ +// These should match with the ARM core's copy of ipc_defines.h + /// Semaphores // Should never reach here #if (MAILBOX_SIZE == 0) @@ -50,3 +57,4 @@ typedef struct { #define MAILBOX_GAME_STATE_IDX (MAILBOX_NEW_BLOCK_LOCATION_IDX + 1) #define MAILBOX_MOVES_COUNT_IDX (MAILBOX_GAME_STATE_IDX + 1) +#endif // EXAMPLES_MAX32655_DEMO_2048_RISCV_INC_IPC_DEFINES_H_ diff --git a/Examples/MAX32655/Demo_2048/RISCV/main.c b/Examples/MAX32655/Demo_2048/RISCV/main.c index 31a98261ef..703e2b7ca5 100644 --- a/Examples/MAX32655/Demo_2048/RISCV/main.c +++ b/Examples/MAX32655/Demo_2048/RISCV/main.c @@ -112,31 +112,30 @@ void CONTROLLER_KEYPRESS_Callback(mxc_uart_req_t *req, int cb_error) KEYPRESS_INPUT_DIR = INPUT_LEFT; KEYPRESS_READY = true; break; - + case 'd': KEYPRESS_INPUT_DIR = INPUT_RIGHT; KEYPRESS_READY = true; break; - + case 'w': KEYPRESS_INPUT_DIR = INPUT_UP; KEYPRESS_READY = true; break; - + case 's': KEYPRESS_INPUT_DIR = INPUT_DOWN; KEYPRESS_READY = true; break; - + default: KEYPRESS_READY = false; error = Controller_Start(&CONTROLLER_REQ); if (error != E_NO_ERROR) { - PRINT("RISC-V: Error listening for next controller keypress: %d\n", error); - LED_On(LED_RED); + PRINT("RISC-V: Invalid Keypress: %c\n", CONTROLLER_KEYPRESS); } } - + PRINT("RISC-V: Keypress: %c - 0x%02x Error: %d\n", CONTROLLER_KEYPRESS, CONTROLLER_KEYPRESS, cb_error); } @@ -271,7 +270,7 @@ int main(void) if (error != E_NO_ERROR) { PRINT("RISC-V: Error speeding up baud rate: %d\n", error); LED_On(LED_RED); - while(1); + while (1) {} } // Set up Controller Request Struct. @@ -292,14 +291,14 @@ int main(void) if (error != E_NO_ERROR) { PRINT("RISC-V: Semaphore for RISC-V core is busy: %d\n", error); LED_On(LED_GREEN); - while(1); + while (1) {} } error = MXC_SEMA_GetSema(SEMA_IDX_RISCV); if (error != E_NO_ERROR) { PRINT("RISC-V: Semaphore is busy - with previous value: %d\n\n", MXC_SEMA->semaphores[SEMA_IDX_RISCV]); LED_On(LED_RED); - while(1); + while (1) {} } else { PRINT("RISC-V: Semaphore is not busy - with previous value: %d\n\n", MXC_SEMA->semaphores[SEMA_IDX_RISCV]); } @@ -318,14 +317,14 @@ int main(void) if (error != E_NO_ERROR) { PRINT("RISC-V: Error starting the controller: %d\n", error); LED_On(LED_RED); - while(1); + while (1) {} } error = Game_2048_Init(&new_block_idx_location); if (error != E_NO_ERROR) { PRINT("RISC-V: Error starting game: %d\n", error); LED_On(LED_RED); - while(1); + while (1) {} } // Send starting grid to ARM core. @@ -365,7 +364,7 @@ int main(void) PRINT("RISC-V: Blocks did not move.\n"); } - // Check state of game. + // Get the state of the game after finishing latest move. game_state_t game_state = Game_2048_CheckState(); // These functions must be called before PRINT_GRID() and SendGridToARMCore() @@ -393,14 +392,14 @@ int main(void) PRINT("RISCV: Congratulations, you win!\n"); PRINT("RISCV: Ending game.\n"); - while(1); + while (1) {} } else if (game_state == GAME_OVER) { // Signal ARM to finish final display update. MXC_SEMA_FreeSema(SEMA_IDX_ARM); PRINT("RISCV: Game Over. Nice try! Better luck next time.\n"); PRINT("RISCV: Ending game.\n"); - while(1); + while (1) {} } // Listen for next keypress. @@ -410,7 +409,7 @@ int main(void) if (error != E_NO_ERROR) { PRINT("RISC-V: Error listening for next controller keypress: %d\n", error); LED_On(LED_RED); - while(1); + while (1) {} } // Signal ARM to update display. diff --git a/Examples/MAX32655/Demo_2048/RISCV/src/game_2048.c b/Examples/MAX32655/Demo_2048/RISCV/src/game_2048.c index be8a1ef35f..4141092dda 100644 --- a/Examples/MAX32655/Demo_2048/RISCV/src/game_2048.c +++ b/Examples/MAX32655/Demo_2048/RISCV/src/game_2048.c @@ -167,7 +167,7 @@ int Game_2048_Init(uint8_t *new_block_location_idx) } // Should never reach here since we cleared the grid earlier in the function. - if(add_new_block(true, new_block_location_idx) == false) { + if (add_new_block(true, new_block_location_idx) == false) { return E_BAD_STATE; } @@ -208,11 +208,11 @@ inline static bool row_logic_left(void) // If there's only one valid block, don't bother with the same-value pair logic. if (temp_col_num == 1) { MAIN_2048_GRID[row][0] = temp_row[0]; - + // Check if the single block moved left. if (prev_row[0] != MAIN_2048_GRID[row][0]) { blocks_moved = true; - + // Represent the state of the original block location as deleted for // display. for (int col = 3; col >= 0; col--) { @@ -491,9 +491,8 @@ inline static bool column_logic_up(void) static bool column_logic_down(void) { bool blocks_moved = false; - + for (int col = 0; col < 4; col++) { - // Don't waste processing time if column is empty by checking if sum of all blocks in column is 0. if (COLUMN_SUM(col) == 0) { continue; @@ -653,7 +652,7 @@ bool Game_2048_UpdateGrid(input_direction_t direction, uint8_t *new_block_1D_idx printf("UP\n"); blocks_moved = column_logic_up(); break; - + case INPUT_DOWN: printf("DOWN\n"); blocks_moved = column_logic_down(); @@ -663,12 +662,12 @@ bool Game_2048_UpdateGrid(input_direction_t direction, uint8_t *new_block_1D_idx printf("LEFT\n"); blocks_moved = row_logic_left(); break; - + case INPUT_RIGHT: printf("RIGHT\n"); blocks_moved = row_logic_right(); break; - + // Should never reach here. default: return false;