From f91884518bd46f88744ed81693d4cbfdc8561780 Mon Sep 17 00:00:00 2001
From: Rahix <rahix@rahix.de>
Date: Sat, 6 Jul 2019 14:06:06 +0200
Subject: [PATCH] chore(epicardium): Fix style

---
 epicardium/api/caller.c     | 12 +++++++-----
 epicardium/api/caller.h     |  4 ++--
 epicardium/api/common.h     |  2 +-
 epicardium/api/dispatcher.c | 10 +++++-----
 epicardium/api/dispatcher.h |  2 +-
 epicardium/epicardium.h     |  8 ++++----
 epicardium/main.c           | 28 +++++++++++++---------------
 epicardium/modules/serial.c | 17 +++++++----------
 epicardium/modules/serial.h |  2 +-
 epicardium/support.c        | 26 +++++++++++++++-----------
 10 files changed, 56 insertions(+), 55 deletions(-)

diff --git a/epicardium/api/caller.c b/epicardium/api/caller.c
index 9dc240ecb..f1ba675fa 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 092f2fa7b..d9192c85e 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 5b435fa58..a929f301c 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 38b61149a..4675c8d4f 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 4098b162b..a67aa0c40 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 d5af7aefe..12bb9a1a9 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 ab3811c05..7a24021b7 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 ac9e1ce0c..c4492c2a5 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 5e2e17795..e944089cd 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 957e787b8..7d6fb2386 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
-- 
GitLab