Slight naming refactoring
/*---------------------------------------------------------------------------*/
static UART_Handle gh_uart;
-static volatile uart0_input_cb g_input_cb;
-static unsigned char g_char_buf;
+static volatile uart0_input_cb curr_input_cb;
+static unsigned char char_buf;
-static bool g_bIsInit = false;
+static bool is_init;
/*---------------------------------------------------------------------------*/
static void
uart0_cb(UART_Handle handle, void *buf, size_t count)
{
- if (!g_input_cb) { return; }
+ if (!curr_input_cb) { return; }
/*
* Save the current callback function, as this might be overwritten after
* the callback is called.
*/
- const uart0_input_cb currCb = g_input_cb;
- /* Call the callback. Note this might reset g_input_cb */
- currCb(g_char_buf);
+ const uart0_input_cb currCb = curr_input_cb;
+ /* Call the callback. Note this might reset curr_input_cb */
+ currCb(char_buf);
/*
- * If g_input_cb didn't change after the call, do another read.
+ * If curr_input_cb didn't change after the call, do another read.
* Else, the uart0_set_callback was called with a different callback pointer
* and triggered an another read.
*/
- if (currCb == g_input_cb) {
- UART_read(gh_uart, &g_char_buf, 1);
+ if (currCb == curr_input_cb) {
+ UART_read(gh_uart, &char_buf, 1);
}
}
/*---------------------------------------------------------------------------*/
void
uart0_init(void)
{
- if (g_bIsInit) { return; }
- g_bIsInit = true;
+ if (is_init) { return; }
+ is_init = true;
UART_Params params;
UART_Params_init(&params);
@@ -98,7 +98,7 @@ uart0_init(void)
int_fast32_t
uart0_write(const void *buffer, size_t size)
{
- if (!g_bIsInit) {
+ if (!is_init) {
return UART_STATUS_ERROR;
}
return UART_write(gh_uart, buffer, size);
@@ -107,17 +107,17 @@ uart0_write(const void *buffer, size_t size)
int_fast32_t
uart0_set_callback(uart0_input_cb input_cb)
{
- if (!g_bIsInit) {
+ if (!is_init) {
return UART_STATUS_ERROR;
}
- if (g_input_cb == input_cb) {
+ if (curr_input_cb == input_cb) {
return UART_STATUS_SUCCESS;
}
- g_input_cb = input_cb;
+ curr_input_cb = input_cb;
if (input_cb) {
- return UART_read(gh_uart, &g_char_buf, 1);
+ return UART_read(gh_uart, &char_buf, 1);
} else {
UART_readCancel(gh_uart);
return UART_STATUS_SUCCESS;
