Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
card10
firmware
Commits
6fe49323
Verified
Commit
6fe49323
authored
Jul 20, 2019
by
Rahix
Browse files
chore(epicardium): Port modules to use new log
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
18da37fb
Pipeline
#1342
passed with stages
in 4 minutes and 18 seconds
Changes
7
Pipelines
1
Show whitespace changes
Inline
Side-by-side
epicardium/api/genapi.py
View file @
6fe49323
...
...
@@ -165,7 +165,7 @@ def main():
# Generate Dispatcher {{{
with
open
(
args
.
server
,
"w"
)
as
f_dispatcher
:
tmp
=
"""
\
#include
<stdio
.h
>
#include
"modules/log
.h
"
#include "{header}"
void __api_dispatch_call(uint32_t id, void*buffer)
...
...
@@ -201,7 +201,7 @@ void __api_dispatch_call(uint32_t id, void*buffer)
tmp
=
"""
\
default:
/* 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;
}}
}}
...
...
epicardium/cdcacm.c
View file @
6fe49323
...
...
@@ -57,6 +57,8 @@
#include
"cdc_acm.h"
#include
"descriptors.h"
#include
"modules/log.h"
#include
<errno.h>
/***** Definitions *****/
#define EVENT_ENUM_COMP MAXUSB_NUM_EVENTS
...
...
@@ -117,7 +119,7 @@ void delay_us(unsigned int usec)
/******************************************************************************/
void
cdcacm_init
(
void
)
int
cdcacm_init
(
void
)
{
maxusb_cfg_options_t
usb_opts
;
...
...
@@ -135,14 +137,14 @@ void cdcacm_init(void)
/* Initialize the usb module */
if
(
usb_init
(
&
usb_opts
)
!=
0
)
{
printf
(
"usb_init() failed
\n
"
);
while
(
1
)
;
LOG_ERR
(
"cdcacm"
,
"usb_init() failed"
);
return
-
EIO
;
}
/* Initialize the enumeration module */
if
(
enum_init
()
!=
0
)
{
printf
(
"enum_init() failed
\n
"
);
while
(
1
)
;
LOG_ERR
(
"cdcacm"
,
"enum_init() failed"
);
return
-
EIO
;
}
/* Register enumeration data */
...
...
@@ -161,8 +163,8 @@ void cdcacm_init(void)
/* Initialize the class driver */
if
(
acm_init
(
&
config_descriptor
.
comm_interface_descriptor
)
!=
0
)
{
printf
(
"acm_init() failed
\n
"
);
while
(
1
)
;
LOG_ERR
(
"cdcacm"
,
"acm_init() failed"
);
return
-
EIO
;
}
/* Register callbacks */
...
...
@@ -176,6 +178,8 @@ void cdcacm_init(void)
/* TODO: Fix priority */
NVIC_SetPriority
(
USB_IRQn
,
6
);
NVIC_EnableIRQ
(
USB_IRQn
);
return
0
;
}
int
cdcacm_num_read_avail
(
void
)
...
...
epicardium/cdcacm.h
View file @
6fe49323
#ifndef CDCACM_H
#define CDCACM_H
#include
<stdint.h>
void
cdcacm_init
(
void
);
int
cdcacm_init
(
void
);
int
cdcacm_num_read_avail
(
void
);
uint8_t
cdcacm_read
(
void
);
void
cdcacm_write
(
uint8_t
*
data
,
int
len
);
...
...
epicardium/main.c
View file @
6fe49323
...
...
@@ -26,6 +26,7 @@ TaskHandle_t dispatcher_task_id;
*/
void
vApiDispatcher
(
void
*
pvParameters
)
{
LOG_DEBUG
(
"dispatcher"
,
"Ready."
);
while
(
1
)
{
if
(
api_dispatcher_poll
())
{
api_dispatcher_exec
();
...
...
@@ -36,6 +37,8 @@ void vApiDispatcher(void *pvParameters)
int
main
(
void
)
{
LOG_INFO
(
"startup"
,
"Epicardium startup ..."
);
card10_init
();
card10_diag
();
...
...
@@ -45,10 +48,13 @@ int main(void)
/* TODO: Move this to its own function */
SCB
->
SCR
|=
SCB_SCR_SEVONPEND_Msk
;
cdcacm_init
();
if
(
cdcacm_init
()
<
0
)
{
LOG_ERR
(
"startup"
,
"USB-Serial unavailable"
);
}
fatfs_init
();
LOG_
DEBUG
(
"startup"
,
"Initializing tasks ..."
);
LOG_
INFO
(
"startup"
,
"Initializing tasks ..."
);
/* Serial */
if
(
xTaskCreate
(
...
...
epicardium/modules/log.c
View file @
6fe49323
...
...
@@ -21,11 +21,14 @@ int log_msg(const char *subsys, const char *format, ...)
char
*
msg_color
=
""
;
switch
(
format
[
0
])
{
case
'D'
:
msg_color
=
"
\x1B
[2m"
;
break
;
case
'W'
:
msg_color
=
"
\x1B
[1m"
;
break
;
case
'E'
:
msg_color
=
"
\x1B
[31
;1
m"
;
msg_color
=
"
\x1B
[31m"
;
break
;
case
'C'
:
msg_color
=
"
\x1B
[37;41;1m"
;
...
...
epicardium/modules/pmic.c
View file @
6fe49323
...
...
@@ -10,6 +10,7 @@
#include
"epicardium.h"
#include
"modules.h"
#include
"modules/log.h"
/* Task ID for the pmic handler */
static
TaskHandle_t
pmic_task_id
=
NULL
;
...
...
@@ -33,12 +34,11 @@ void vPmicTask(void *pvParameters)
ulTaskNotifyTake
(
pdTRUE
,
delay
);
if
(
count
==
PMIC_PRESS_SLEEP
)
{
printf
(
"pmic: Sleep
\n
"
"[[ Unimplemented ]]
\n
"
);
LOG_ERR
(
"pmic"
,
"Sleep [[ Unimplemented ]]"
);
}
if
(
count
==
PMIC_PRESS_POWEROFF
)
{
printf
(
"pmic
:
Poweroff
\n
"
);
LOG_INFO
(
"pmic
"
,
"
Poweroff"
);
MAX77650_setSFT_RST
(
0x2
);
}
...
...
@@ -52,7 +52,7 @@ void vPmicTask(void *pvParameters)
if
(
int_flag
&
MAX77650_INT_nEN_R
)
{
/* Button was pressed */
if
(
count
<
PMIC_PRESS_SLEEP
)
{
printf
(
"pmic
:
Reset
\n
"
);
LOG_INFO
(
"pmic
"
,
"
Reset"
);
/*
* Give the UART fifo time to clear.
* TODO: Do this properly
...
...
@@ -69,8 +69,7 @@ void vPmicTask(void *pvParameters)
/* TODO: Remove when all interrupts are handled */
if
(
int_flag
&
~
(
MAX77650_INT_nEN_F
|
MAX77650_INT_nEN_R
))
{
printf
(
"=====> WARNING <=====
\n
"
"* Unhandled PMIC Interrupt: %x
\n
"
,
LOG_WARN
(
"pmic"
,
"Unhandled PMIC Interrupt: %x"
,
int_flag
);
}
...
...
epicardium/modules/serial.c
View file @
6fe49323
...
...
@@ -11,6 +11,7 @@
#include
"queue.h"
#include
"modules.h"
#include
"modules/log.h"
/* Task ID for the serial handler */
TaskHandle_t
serial_task_id
=
NULL
;
...
...
@@ -93,7 +94,7 @@ void vSerialTask(void *pvParameters)
while
(
1
)
{
int
ret
=
UART_ReadAsync
(
ConsoleUart
,
&
read_req
);
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
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment