Skip to content
Snippets Groups Projects
Verified Commit f9188451 authored by rahix's avatar rahix
Browse files

chore(epicardium): Fix style

parent 4c419805
No related branches found
No related tags found
No related merge requests found
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
#include "sema.h" #include "sema.h"
#include "api/caller.h" #include "api/caller.h"
#define MXC_ASSERT_ENABLE #define MXC_ASSERT_ENABLE
#include "mxc_assert.h" #include "mxc_assert.h"
void*_api_call_start(api_id_t id, uintptr_t size) void *_api_call_start(api_id_t id, uintptr_t size)
{ {
while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {} while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {
}
if (API_CALL_MEM->call_flag != _API_FLAG_IDLE) { if (API_CALL_MEM->call_flag != _API_FLAG_IDLE) {
/* /*
...@@ -26,7 +27,7 @@ void*_api_call_start(api_id_t id, uintptr_t size) ...@@ -26,7 +27,7 @@ void*_api_call_start(api_id_t id, uintptr_t size)
return API_CALL_MEM->buffer; return API_CALL_MEM->buffer;
} }
void*_api_call_transact(void*buffer) void *_api_call_transact(void *buffer)
{ {
API_CALL_MEM->call_flag = _API_FLAG_CALLING; API_CALL_MEM->call_flag = _API_FLAG_CALLING;
SEMA_FreeSema(_API_SEMAPHORE); SEMA_FreeSema(_API_SEMAPHORE);
...@@ -39,7 +40,8 @@ void*_api_call_transact(void*buffer) ...@@ -39,7 +40,8 @@ void*_api_call_transact(void*buffer)
/* Wait for the dispather to return */ /* Wait for the dispather to return */
__WFE(); __WFE();
while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {} while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {
}
if (API_CALL_MEM->call_flag == _API_FLAG_RETURNED) { if (API_CALL_MEM->call_flag == _API_FLAG_RETURNED) {
break; break;
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* to fill. NULL if an error occured or no buffer of the requested * to fill. NULL if an error occured or no buffer of the requested
* size is available. * size is available.
*/ */
void*_api_call_start(api_id_t id, uintptr_t size); void *_api_call_start(api_id_t id, uintptr_t size);
/* /*
* Actually do the API call that was previously initiated using * Actually do the API call that was previously initiated using
...@@ -26,4 +26,4 @@ void*_api_call_start(api_id_t id, uintptr_t size); ...@@ -26,4 +26,4 @@ void*_api_call_start(api_id_t id, uintptr_t size);
* Returns: * Returns:
* - Pointer to a buffer containing the return value * - Pointer to a buffer containing the return value
*/ */
void*_api_call_transact(void*buffer); void *_api_call_transact(void *buffer);
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#define _API_SEMAPHORE 0 #define _API_SEMAPHORE 0
/* Type of API IDs */ /* Type of API IDs */
typedef uint32_t api_id_t ; typedef uint32_t api_id_t;
#define _API_FLAG_IDLE 0 #define _API_FLAG_IDLE 0
#define _API_FLAG_CALLING 1 #define _API_FLAG_CALLING 1
......
...@@ -7,16 +7,15 @@ int api_dispatcher_init() ...@@ -7,16 +7,15 @@ int api_dispatcher_init()
{ {
int ret; int ret;
ret = SEMA_Init(NULL); ret = SEMA_Init(NULL);
API_CALL_MEM->call_flag = _API_FLAG_IDLE; API_CALL_MEM->call_flag = _API_FLAG_IDLE;
/* /*
* Enable TX events for both cores. * Enable TX events for both cores.
* TODO: Is this the right place? * TODO: Is this the right place?
*/ */
MXC_GCR->evten |= 0 MXC_GCR->evten |=
| MXC_F_GCR_EVTEN_CPU0TXEVENT MXC_F_GCR_EVTEN_CPU0TXEVENT | MXC_F_GCR_EVTEN_CPU1TXEVENT;
| MXC_F_GCR_EVTEN_CPU1TXEVENT;
return ret; return ret;
} }
...@@ -29,7 +28,8 @@ bool api_dispatcher_poll_once() ...@@ -29,7 +28,8 @@ bool api_dispatcher_poll_once()
return false; return false;
} }
while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {} while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {
}
if (API_CALL_MEM->call_flag != _API_FLAG_CALLING) { if (API_CALL_MEM->call_flag != _API_FLAG_CALLING) {
SEMA_FreeSema(_API_SEMAPHORE); SEMA_FreeSema(_API_SEMAPHORE);
......
...@@ -23,4 +23,4 @@ bool api_dispatcher_poll(); ...@@ -23,4 +23,4 @@ bool api_dispatcher_poll();
api_id_t api_dispatcher_exec(); api_id_t api_dispatcher_exec();
/* This function is defined by the generated dispatcher code */ /* This function is defined by the generated dispatcher code */
void __api_dispatch_call(api_id_t id, void*buffer); void __api_dispatch_call(api_id_t id, void *buffer);
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
#include <stdint.h> #include <stdint.h>
#ifndef API #ifndef API
# define API(id, def) def #define API(id, def) def
#endif #endif
#define API_UART_WRITE 0x1 #define API_UART_WRITE 0x1
API(API_UART_WRITE, void epic_uart_write_str(const char*str, intptr_t length)); API(API_UART_WRITE, void epic_uart_write_str(const char *str, intptr_t length));
#define API_UART_READ 0x2 #define API_UART_READ 0x2
API(API_UART_READ, char epic_uart_read_chr(void)); API(API_UART_READ, char epic_uart_read_chr(void));
#define API_LEDS_SET 0x3 #define API_LEDS_SET 0x3
API(API_LEDS_SET, void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b)); API(API_LEDS_SET, void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b));
#endif /* _EPICARDIUM_H */ #endif /* _EPICARDIUM_H */
...@@ -20,7 +20,7 @@ TaskHandle_t dispatcher_task_id; ...@@ -20,7 +20,7 @@ TaskHandle_t dispatcher_task_id;
* API dispatcher task. This task will sleep until an API call is issued and * API dispatcher task. This task will sleep until an API call is issued and
* then wake up to dispatch it. * then wake up to dispatch it.
*/ */
void vApiDispatcher(void*pvParameters) void vApiDispatcher(void *pvParameters)
{ {
while (1) { while (1) {
if (api_dispatcher_poll()) { if (api_dispatcher_poll()) {
...@@ -61,25 +61,23 @@ int main(void) ...@@ -61,25 +61,23 @@ int main(void)
/* Serial */ /* Serial */
if (xTaskCreate( if (xTaskCreate(
vSerialTask, vSerialTask,
(const char*)"Serial", (const char *)"Serial",
configMINIMAL_STACK_SIZE, configMINIMAL_STACK_SIZE,
NULL, NULL,
tskIDLE_PRIORITY + 1, tskIDLE_PRIORITY + 1,
NULL NULL) != pdPASS) {
) != pdPASS) {
printf("Failed to create serial-comms task!\n"); printf("Failed to create serial-comms task!\n");
abort(); abort();
} }
if (xTaskCreate( if (xTaskCreate(
vApiDispatcher, vApiDispatcher,
(const char*)"API Dispatcher", (const char *)"API Dispatcher",
configMINIMAL_STACK_SIZE, configMINIMAL_STACK_SIZE,
NULL, NULL,
tskIDLE_PRIORITY + 2, tskIDLE_PRIORITY + 2,
&dispatcher_task_id &dispatcher_task_id) != pdPASS) {
) != pdPASS) {
printf("Failed to create api dispatcher task!\n"); printf("Failed to create api dispatcher task!\n");
abort(); abort();
} }
......
...@@ -16,17 +16,17 @@ ...@@ -16,17 +16,17 @@
TaskHandle_t serial_task_id = NULL; TaskHandle_t serial_task_id = NULL;
/* The serial console in use (UART0) */ /* The serial console in use (UART0) */
extern mxc_uart_regs_t* ConsoleUart; extern mxc_uart_regs_t *ConsoleUart;
/* Read queue, filled by both UART and CDCACM */ /* Read queue, filled by both UART and CDCACM */
static QueueHandle_t read_queue; static QueueHandle_t read_queue;
/* /*
* API-call to write a string. Output goes to both CDCACM and UART * API-call to write a string. Output goes to both CDCACM and UART
*/ */
void epic_uart_write_str(char*str, intptr_t length) void epic_uart_write_str(char *str, intptr_t length)
{ {
UART_Write(ConsoleUart, (uint8_t*)str, length); UART_Write(ConsoleUart, (uint8_t *)str, length);
cdcacm_write((uint8_t*)str, length); cdcacm_write((uint8_t *)str, length);
} }
/* /*
...@@ -45,7 +45,7 @@ void UART0_IRQHandler(void) ...@@ -45,7 +45,7 @@ void UART0_IRQHandler(void)
UART_Handler(ConsoleUart); UART_Handler(ConsoleUart);
} }
static void uart_callback(uart_req_t*req, int error) static void uart_callback(uart_req_t *req, int error)
{ {
BaseType_t xHigherPriorityTaskWoken = pdFALSE; BaseType_t xHigherPriorityTaskWoken = pdFALSE;
vTaskNotifyGiveFromISR(serial_task_id, &xHigherPriorityTaskWoken); vTaskNotifyGiveFromISR(serial_task_id, &xHigherPriorityTaskWoken);
...@@ -65,7 +65,7 @@ static void enqueue_char(char chr) ...@@ -65,7 +65,7 @@ static void enqueue_char(char chr)
} }
} }
void vSerialTask(void*pvParameters) void vSerialTask(void *pvParameters)
{ {
static uint8_t buffer[sizeof(char) * SERIAL_READ_BUFFER_SIZE]; static uint8_t buffer[sizeof(char) * SERIAL_READ_BUFFER_SIZE];
static StaticQueue_t read_queue_data; static StaticQueue_t read_queue_data;
...@@ -74,10 +74,7 @@ void vSerialTask(void*pvParameters) ...@@ -74,10 +74,7 @@ void vSerialTask(void*pvParameters)
/* Setup read queue */ /* Setup read queue */
read_queue = xQueueCreateStatic( read_queue = xQueueCreateStatic(
SERIAL_READ_BUFFER_SIZE, SERIAL_READ_BUFFER_SIZE, sizeof(char), buffer, &read_queue_data
sizeof(char),
buffer,
&read_queue_data
); );
/* Setup UART interrupt */ /* Setup UART interrupt */
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
#define SERIAL_READ_BUFFER_SIZE 128 #define SERIAL_READ_BUFFER_SIZE 128
void vSerialTask(void*pvParameters); void vSerialTask(void *pvParameters);
#endif /* EPIC_SERIAL_H */ #endif /* EPIC_SERIAL_H */
...@@ -26,9 +26,9 @@ void pre_idle_sleep(TickType_t xExpectedIdleTime) ...@@ -26,9 +26,9 @@ void pre_idle_sleep(TickType_t xExpectedIdleTime)
* TODO: Ensure this is actually correct and does not have any * TODO: Ensure this is actually correct and does not have any
* race conditions. * race conditions.
*/ */
__asm volatile( "dsb" ::: "memory" ); __asm volatile("dsb" ::: "memory");
__asm volatile( "wfe" ); __asm volatile("wfe");
__asm volatile( "isb" ); __asm volatile("isb");
} }
} }
...@@ -42,23 +42,27 @@ void post_idle_sleep(TickType_t xExpectedIdleTime) ...@@ -42,23 +42,27 @@ void post_idle_sleep(TickType_t xExpectedIdleTime)
xTaskNotifyGive(dispatcher_task_id); xTaskNotifyGive(dispatcher_task_id);
} }
// Do card10 house keeping. E.g. polling the i2c devices if they triggered an interrupt /*
// TODO: Do this in a more task fokused way (high/low ISR) * Do card10 house keeping. e.g. polling the i2c devices if they
card10_poll(); * triggered an interrupt.
*
* TODO: Do this in a more task focused way (high/low ISR)
*/
card10_poll();
} }
void vApplicationGetIdleTaskMemory( void vApplicationGetIdleTaskMemory(
StaticTask_t**ppxIdleTaskTCBBuffer, StaticTask_t **ppxIdleTaskTCBBuffer,
StackType_t**ppxIdleTaskStackBuffer, StackType_t **ppxIdleTaskStackBuffer,
uint32_t *pulIdleTaskStackSize) uint32_t *pulIdleTaskStackSize
{ ) {
/* /*
* If the buffers to be provided to the Idle task are declared inside this * If the buffers to be provided to the Idle task are declared inside this
* function then they must be declared static - otherwise they will be allocated on * function then they must be declared static - otherwise they will be allocated on
* the stack and so not exists after this function exits. * the stack and so not exists after this function exits.
*/ */
static StaticTask_t xIdleTaskTCB; static StaticTask_t xIdleTaskTCB;
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE];
/* /*
* Pass out a pointer to the StaticTask_t structure in which the Idle task's * Pass out a pointer to the StaticTask_t structure in which the Idle task's
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment