diff --git a/epicardium/api/caller.c b/epicardium/api/caller.c index 9dc240ecb28fad648f0ff4173f5f98ae8e19ab37..f1ba675fa98b03d0ee6411e2a0271829174d809d 100644 --- a/epicardium/api/caller.c +++ b/epicardium/api/caller.c @@ -2,12 +2,13 @@ #include "sema.h" #include "api/caller.h" -#define MXC_ASSERT_ENABLE +#define MXC_ASSERT_ENABLE #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) { /* @@ -26,7 +27,7 @@ void*_api_call_start(api_id_t id, uintptr_t size) 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; SEMA_FreeSema(_API_SEMAPHORE); @@ -39,7 +40,8 @@ void*_api_call_transact(void*buffer) /* Wait for the dispather to return */ __WFE(); - while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {} + while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) { + } if (API_CALL_MEM->call_flag == _API_FLAG_RETURNED) { break; } diff --git a/epicardium/api/caller.h b/epicardium/api/caller.h index 092f2fa7b21ae06ef9f3346eda16b749a569cd8d..d9192c85e133502c005d2e868eebbf39598dd7ff 100644 --- a/epicardium/api/caller.h +++ b/epicardium/api/caller.h @@ -14,7 +14,7 @@ * to fill. NULL if an error occured or no buffer of the requested * 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 @@ -26,4 +26,4 @@ void*_api_call_start(api_id_t id, uintptr_t size); * Returns: * - Pointer to a buffer containing the return value */ -void*_api_call_transact(void*buffer); +void *_api_call_transact(void *buffer); diff --git a/epicardium/api/common.h b/epicardium/api/common.h index 5b435fa587479faf12e1a59d7f592c0d4a717384..a929f301cabb530ed3e430a021dd4dd441acf372 100644 --- a/epicardium/api/common.h +++ b/epicardium/api/common.h @@ -8,7 +8,7 @@ #define _API_SEMAPHORE 0 /* Type of API IDs */ -typedef uint32_t api_id_t ; +typedef uint32_t api_id_t; #define _API_FLAG_IDLE 0 #define _API_FLAG_CALLING 1 diff --git a/epicardium/api/dispatcher.c b/epicardium/api/dispatcher.c index 38b61149a0befab28fc9dcc548a7fbfe3b4f6260..4675c8d4f53f1e90b2d0809cb5979589e7a58af1 100644 --- a/epicardium/api/dispatcher.c +++ b/epicardium/api/dispatcher.c @@ -7,16 +7,15 @@ int api_dispatcher_init() { int ret; - ret = SEMA_Init(NULL); + ret = SEMA_Init(NULL); API_CALL_MEM->call_flag = _API_FLAG_IDLE; /* * Enable TX events for both cores. * TODO: Is this the right place? */ - MXC_GCR->evten |= 0 - | MXC_F_GCR_EVTEN_CPU0TXEVENT - | MXC_F_GCR_EVTEN_CPU1TXEVENT; + MXC_GCR->evten |= + MXC_F_GCR_EVTEN_CPU0TXEVENT | MXC_F_GCR_EVTEN_CPU1TXEVENT; return ret; } @@ -29,7 +28,8 @@ bool api_dispatcher_poll_once() 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) { SEMA_FreeSema(_API_SEMAPHORE); diff --git a/epicardium/api/dispatcher.h b/epicardium/api/dispatcher.h index 4098b162bfed61097b39b3ae753399fe6b4018b8..a67aa0c40df25968f51809da9c4401b5c3ef1a7a 100644 --- a/epicardium/api/dispatcher.h +++ b/epicardium/api/dispatcher.h @@ -23,4 +23,4 @@ bool api_dispatcher_poll(); api_id_t api_dispatcher_exec(); /* 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); diff --git a/epicardium/epicardium.h b/epicardium/epicardium.h index d5af7aefe1262e31df689181ceba6f903ba4c079..12bb9a1a9d6fdbd4f3a1d2efa3cc393fa8a3dccd 100644 --- a/epicardium/epicardium.h +++ b/epicardium/epicardium.h @@ -3,16 +3,16 @@ #include <stdint.h> #ifndef API -# define API(id, def) def +#define API(id, def) def #endif #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)); -#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)); #endif /* _EPICARDIUM_H */ diff --git a/epicardium/main.c b/epicardium/main.c index ab3811c05c96b661d0837a8bc2a86d750d2cbc36..7a24021b72bd964e8848cc54354b9ddfed6e7b3b 100644 --- a/epicardium/main.c +++ b/epicardium/main.c @@ -20,7 +20,7 @@ TaskHandle_t dispatcher_task_id; * API dispatcher task. This task will sleep until an API call is issued and * then wake up to dispatch it. */ -void vApiDispatcher(void*pvParameters) +void vApiDispatcher(void *pvParameters) { while (1) { if (api_dispatcher_poll()) { @@ -61,25 +61,23 @@ int main(void) /* Serial */ if (xTaskCreate( - vSerialTask, - (const char*)"Serial", - configMINIMAL_STACK_SIZE, - NULL, - tskIDLE_PRIORITY + 1, - NULL - ) != pdPASS) { + vSerialTask, + (const char *)"Serial", + configMINIMAL_STACK_SIZE, + NULL, + tskIDLE_PRIORITY + 1, + NULL) != pdPASS) { printf("Failed to create serial-comms task!\n"); abort(); } if (xTaskCreate( - vApiDispatcher, - (const char*)"API Dispatcher", - configMINIMAL_STACK_SIZE, - NULL, - tskIDLE_PRIORITY + 2, - &dispatcher_task_id - ) != pdPASS) { + vApiDispatcher, + (const char *)"API Dispatcher", + configMINIMAL_STACK_SIZE, + NULL, + tskIDLE_PRIORITY + 2, + &dispatcher_task_id) != pdPASS) { printf("Failed to create api dispatcher task!\n"); abort(); } diff --git a/epicardium/modules/serial.c b/epicardium/modules/serial.c index ac9e1ce0c72fca5b998fb546805d2e57e9722c45..c4492c2a5af0f63b072c5475c79f1b42ff129027 100644 --- a/epicardium/modules/serial.c +++ b/epicardium/modules/serial.c @@ -16,17 +16,17 @@ TaskHandle_t serial_task_id = NULL; /* 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 */ static QueueHandle_t read_queue; /* * 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); - cdcacm_write((uint8_t*)str, length); + UART_Write(ConsoleUart, (uint8_t *)str, length); + cdcacm_write((uint8_t *)str, length); } /* @@ -45,7 +45,7 @@ void UART0_IRQHandler(void) 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; vTaskNotifyGiveFromISR(serial_task_id, &xHigherPriorityTaskWoken); @@ -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 StaticQueue_t read_queue_data; @@ -74,10 +74,7 @@ void vSerialTask(void*pvParameters) /* Setup read queue */ read_queue = xQueueCreateStatic( - SERIAL_READ_BUFFER_SIZE, - sizeof(char), - buffer, - &read_queue_data + SERIAL_READ_BUFFER_SIZE, sizeof(char), buffer, &read_queue_data ); /* Setup UART interrupt */ diff --git a/epicardium/modules/serial.h b/epicardium/modules/serial.h index 5e2e1779505c03de27ba8ed60888c9845eb97597..e944089cd952f31a5f6598deaca11d342c51e196 100644 --- a/epicardium/modules/serial.h +++ b/epicardium/modules/serial.h @@ -3,6 +3,6 @@ #define SERIAL_READ_BUFFER_SIZE 128 -void vSerialTask(void*pvParameters); +void vSerialTask(void *pvParameters); #endif /* EPIC_SERIAL_H */ diff --git a/epicardium/support.c b/epicardium/support.c index 957e787b8e2ee2201f55627471999461784068be..7d6fb23863e111c311bf2945a755e4e8bcd2be9c 100644 --- a/epicardium/support.c +++ b/epicardium/support.c @@ -26,9 +26,9 @@ void pre_idle_sleep(TickType_t xExpectedIdleTime) * TODO: Ensure this is actually correct and does not have any * race conditions. */ - __asm volatile( "dsb" ::: "memory" ); - __asm volatile( "wfe" ); - __asm volatile( "isb" ); + __asm volatile("dsb" ::: "memory"); + __asm volatile("wfe"); + __asm volatile("isb"); } } @@ -42,23 +42,27 @@ void post_idle_sleep(TickType_t xExpectedIdleTime) 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) - card10_poll(); + /* + * Do card10 house keeping. e.g. polling the i2c devices if they + * triggered an interrupt. + * + * TODO: Do this in a more task focused way (high/low ISR) + */ + card10_poll(); } void vApplicationGetIdleTaskMemory( - StaticTask_t**ppxIdleTaskTCBBuffer, - StackType_t**ppxIdleTaskStackBuffer, - uint32_t *pulIdleTaskStackSize) -{ + StaticTask_t **ppxIdleTaskTCBBuffer, + StackType_t **ppxIdleTaskStackBuffer, + uint32_t *pulIdleTaskStackSize +) { /* * 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 * the stack and so not exists after this function exits. */ 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