Verified Commit 6fe49323 authored by Rahix's avatar Rahix
Browse files

chore(epicardium): Port modules to use new log



Signed-off-by: Rahix's avatarRahix <rahix@rahix.de>
parent 18da37fb
Pipeline #1342 passed with stages
in 4 minutes and 18 seconds
...@@ -165,7 +165,7 @@ def main(): ...@@ -165,7 +165,7 @@ def main():
# Generate Dispatcher {{{ # Generate Dispatcher {{{
with open(args.server, "w") as f_dispatcher: with open(args.server, "w") as f_dispatcher:
tmp = """\ tmp = """\
#include <stdio.h> #include "modules/log.h"
#include "{header}" #include "{header}"
void __api_dispatch_call(uint32_t id, void*buffer) void __api_dispatch_call(uint32_t id, void*buffer)
...@@ -201,7 +201,7 @@ void __api_dispatch_call(uint32_t id, void*buffer) ...@@ -201,7 +201,7 @@ void __api_dispatch_call(uint32_t id, void*buffer)
tmp = """\ tmp = """\
default: default:
/* TODO: Better error handling */ /* TODO: Better error handling */
printf("Error: API function %lx is unknown!!\\n", id); LOG_ERR("api-dispatcher", "API function 0x%lx is unknown!!", id);
break; break;
}} }}
}} }}
......
...@@ -57,6 +57,8 @@ ...@@ -57,6 +57,8 @@
#include "cdc_acm.h" #include "cdc_acm.h"
#include "descriptors.h" #include "descriptors.h"
#include "modules/log.h"
#include <errno.h>
/***** Definitions *****/ /***** Definitions *****/
#define EVENT_ENUM_COMP MAXUSB_NUM_EVENTS #define EVENT_ENUM_COMP MAXUSB_NUM_EVENTS
...@@ -117,7 +119,7 @@ void delay_us(unsigned int usec) ...@@ -117,7 +119,7 @@ void delay_us(unsigned int usec)
/******************************************************************************/ /******************************************************************************/
void cdcacm_init(void) int cdcacm_init(void)
{ {
maxusb_cfg_options_t usb_opts; maxusb_cfg_options_t usb_opts;
...@@ -135,14 +137,14 @@ void cdcacm_init(void) ...@@ -135,14 +137,14 @@ void cdcacm_init(void)
/* Initialize the usb module */ /* Initialize the usb module */
if (usb_init(&usb_opts) != 0) { if (usb_init(&usb_opts) != 0) {
printf("usb_init() failed\n"); LOG_ERR("cdcacm", "usb_init() failed");
while (1); return -EIO;
} }
/* Initialize the enumeration module */ /* Initialize the enumeration module */
if (enum_init() != 0) { if (enum_init() != 0) {
printf("enum_init() failed\n"); LOG_ERR("cdcacm", "enum_init() failed");
while (1); return -EIO;
} }
/* Register enumeration data */ /* Register enumeration data */
...@@ -161,8 +163,8 @@ void cdcacm_init(void) ...@@ -161,8 +163,8 @@ void cdcacm_init(void)
/* Initialize the class driver */ /* Initialize the class driver */
if (acm_init(&config_descriptor.comm_interface_descriptor) != 0) { if (acm_init(&config_descriptor.comm_interface_descriptor) != 0) {
printf("acm_init() failed\n"); LOG_ERR("cdcacm", "acm_init() failed");
while (1); return -EIO;
} }
/* Register callbacks */ /* Register callbacks */
...@@ -176,6 +178,8 @@ void cdcacm_init(void) ...@@ -176,6 +178,8 @@ void cdcacm_init(void)
/* TODO: Fix priority */ /* TODO: Fix priority */
NVIC_SetPriority(USB_IRQn, 6); NVIC_SetPriority(USB_IRQn, 6);
NVIC_EnableIRQ(USB_IRQn); NVIC_EnableIRQ(USB_IRQn);
return 0;
} }
int cdcacm_num_read_avail(void) int cdcacm_num_read_avail(void)
......
#ifndef CDCACM_H #ifndef CDCACM_H
#define CDCACM_H #define CDCACM_H
#include <stdint.h>
void cdcacm_init(void); int cdcacm_init(void);
int cdcacm_num_read_avail(void); int cdcacm_num_read_avail(void);
uint8_t cdcacm_read(void); uint8_t cdcacm_read(void);
void cdcacm_write(uint8_t *data, int len); void cdcacm_write(uint8_t *data, int len);
......
...@@ -26,6 +26,7 @@ TaskHandle_t dispatcher_task_id; ...@@ -26,6 +26,7 @@ TaskHandle_t dispatcher_task_id;
*/ */
void vApiDispatcher(void *pvParameters) void vApiDispatcher(void *pvParameters)
{ {
LOG_DEBUG("dispatcher", "Ready.");
while (1) { while (1) {
if (api_dispatcher_poll()) { if (api_dispatcher_poll()) {
api_dispatcher_exec(); api_dispatcher_exec();
...@@ -36,6 +37,8 @@ void vApiDispatcher(void *pvParameters) ...@@ -36,6 +37,8 @@ void vApiDispatcher(void *pvParameters)
int main(void) int main(void)
{ {
LOG_INFO("startup", "Epicardium startup ...");
card10_init(); card10_init();
card10_diag(); card10_diag();
...@@ -45,10 +48,13 @@ int main(void) ...@@ -45,10 +48,13 @@ int main(void)
/* TODO: Move this to its own function */ /* TODO: Move this to its own function */
SCB->SCR |= SCB_SCR_SEVONPEND_Msk; SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
cdcacm_init(); if (cdcacm_init() < 0) {
LOG_ERR("startup", "USB-Serial unavailable");
}
fatfs_init(); fatfs_init();
LOG_DEBUG("startup", "Initializing tasks ..."); LOG_INFO("startup", "Initializing tasks ...");
/* Serial */ /* Serial */
if (xTaskCreate( if (xTaskCreate(
......
...@@ -21,11 +21,14 @@ int log_msg(const char *subsys, const char *format, ...) ...@@ -21,11 +21,14 @@ int log_msg(const char *subsys, const char *format, ...)
char *msg_color = ""; char *msg_color = "";
switch (format[0]) { switch (format[0]) {
case 'D':
msg_color = "\x1B[2m";
break;
case 'W': case 'W':
msg_color = "\x1B[1m"; msg_color = "\x1B[1m";
break; break;
case 'E': case 'E':
msg_color = "\x1B[31;1m"; msg_color = "\x1B[31m";
break; break;
case 'C': case 'C':
msg_color = "\x1B[37;41;1m"; msg_color = "\x1B[37;41;1m";
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "epicardium.h" #include "epicardium.h"
#include "modules.h" #include "modules.h"
#include "modules/log.h"
/* Task ID for the pmic handler */ /* Task ID for the pmic handler */
static TaskHandle_t pmic_task_id = NULL; static TaskHandle_t pmic_task_id = NULL;
...@@ -33,12 +34,11 @@ void vPmicTask(void *pvParameters) ...@@ -33,12 +34,11 @@ void vPmicTask(void *pvParameters)
ulTaskNotifyTake(pdTRUE, delay); ulTaskNotifyTake(pdTRUE, delay);
if (count == PMIC_PRESS_SLEEP) { if (count == PMIC_PRESS_SLEEP) {
printf("pmic: Sleep\n" LOG_ERR("pmic", "Sleep [[ Unimplemented ]]");
"[[ Unimplemented ]]\n");
} }
if (count == PMIC_PRESS_POWEROFF) { if (count == PMIC_PRESS_POWEROFF) {
printf("pmic: Poweroff\n"); LOG_INFO("pmic", "Poweroff");
MAX77650_setSFT_RST(0x2); MAX77650_setSFT_RST(0x2);
} }
...@@ -52,7 +52,7 @@ void vPmicTask(void *pvParameters) ...@@ -52,7 +52,7 @@ void vPmicTask(void *pvParameters)
if (int_flag & MAX77650_INT_nEN_R) { if (int_flag & MAX77650_INT_nEN_R) {
/* Button was pressed */ /* Button was pressed */
if (count < PMIC_PRESS_SLEEP) { if (count < PMIC_PRESS_SLEEP) {
printf("pmic: Reset\n"); LOG_INFO("pmic", "Reset");
/* /*
* Give the UART fifo time to clear. * Give the UART fifo time to clear.
* TODO: Do this properly * TODO: Do this properly
...@@ -69,8 +69,7 @@ void vPmicTask(void *pvParameters) ...@@ -69,8 +69,7 @@ void vPmicTask(void *pvParameters)
/* TODO: Remove when all interrupts are handled */ /* TODO: Remove when all interrupts are handled */
if (int_flag & ~(MAX77650_INT_nEN_F | MAX77650_INT_nEN_R)) { if (int_flag & ~(MAX77650_INT_nEN_F | MAX77650_INT_nEN_R)) {
printf("=====> WARNING <=====\n" LOG_WARN("pmic", "Unhandled PMIC Interrupt: %x",
"* Unhandled PMIC Interrupt: %x\n",
int_flag); int_flag);
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "queue.h" #include "queue.h"
#include "modules.h" #include "modules.h"
#include "modules/log.h"
/* Task ID for the serial handler */ /* Task ID for the serial handler */
TaskHandle_t serial_task_id = NULL; TaskHandle_t serial_task_id = NULL;
...@@ -93,7 +94,7 @@ void vSerialTask(void *pvParameters) ...@@ -93,7 +94,7 @@ void vSerialTask(void *pvParameters)
while (1) { while (1) {
int ret = UART_ReadAsync(ConsoleUart, &read_req); int ret = UART_ReadAsync(ConsoleUart, &read_req);
if (ret != E_NO_ERROR && ret != E_BUSY) { if (ret != E_NO_ERROR && ret != E_BUSY) {
printf("error reading uart: %d\n", ret); LOG_ERR("serial", "error reading uart: %d", ret);
vTaskDelay(portMAX_DELAY); vTaskDelay(portMAX_DELAY);
} }
......
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