Skip to content

Commit

Permalink
Fix typos, lower baudrate to 115200, move mailbox/semaphore definitio…
Browse files Browse the repository at this point in the history
…ns outside of RISCV to hide intellisense not finding definition error (build/buildrv/project_defines.h)
  • Loading branch information
sihyung-maxim committed Sep 16, 2024
1 parent 55b2f18 commit c5be3fc
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 36 deletions.
5 changes: 4 additions & 1 deletion Examples/MAX32655/Demo_2048/ARM/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
],
"C_Cpp.default.forcedInclude": [
"${workspaceFolder}/build/project_defines.h"
]
],
"files.associations": {
"graphics.h": "c"
}
}

4 changes: 2 additions & 2 deletions Examples/MAX32655/Demo_2048/ARM/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

// Match the Console's baud rate to what the controller will be set to
// for the RISC-V as they share the same port.
#define RISCV_CONTROLLER_BAUD (2000000)
#define RISCV_CONTROLLER_BAUD (115200)

/// Semaphores
// Should never reach here
Expand All @@ -74,7 +74,7 @@ typedef struct {
#endif
} mxcSemaBox_t;

#define MAILBOX_MAIN_GRID_IDX (0) // Main grid indexs are from 0 to (16 blocks * 4 bytes) - 1.
#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)
Expand Down
52 changes: 52 additions & 0 deletions Examples/MAX32655/Demo_2048/RISCV/inc/ipc_defines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/******************************************************************************
*
* 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.
*
******************************************************************************/

/* **** Includes **** */

/* **** Definitions **** */

/// 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)

38 changes: 5 additions & 33 deletions Examples/MAX32655/Demo_2048/RISCV/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
// Application Libraries
#include "controller.h"
#include "game_2048.h"
#include "ipc_defines.h"

/***** Definitions *****/

Expand All @@ -50,41 +51,12 @@
#endif

/// Controller Settings.
// Set to its fastest supported speed (3Mbps when tested).
// Change UART speeds here, if needed. 115200 was more than enough, but users
// have the option to increase the speed here.
// UART speed up is set at the beginning of BOTH ARM and RISC-V main code
// because SystemInit for both cores default the UART baud rate to
// 115200.
#define CONTROLLER_UART_BAUD (2000000)

/// 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 indexs 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)
// 115200.
#define CONTROLLER_UART_BAUD (115200)

/* **** Globals **** */
// Defined in sema_reva.c
Expand Down

0 comments on commit c5be3fc

Please sign in to comment.