Verified Commit f9188451 authored by Rahix's avatar Rahix
Browse files

chore(epicardium): Fix style

parent 4c419805
......@@ -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;
}
......
......@@ -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);
......@@ -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
......
......@@ -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);
......
......@@ -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);
......@@ -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 */
......@@ -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();
}
......
......@@ -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 */
......
......@@ -3,6 +3,6 @@
#define SERIAL_READ_BUFFER_SIZE 128
void vSerialTask(void*pvParameters);
void vSerialTask(void *pvParameters);
#endif /* EPIC_SERIAL_H */
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment