From e297a71e8c93a4fde26ea3c6803f74a91687f2a4 Mon Sep 17 00:00:00 2001 From: Neil Jones <neil.jones@imgtec.com> Date: Mon, 15 Jan 2018 11:04:20 +0000 Subject: [PATCH] mips: Correct usage of USEMODULE In CPU definitions we should not be explicilty naming peripheral modules to use via USEMODULE (one should use FEATURES_PROVIDED instead). Plus add missing cpu_init() and periph_init() methods. This commit removes periph_hwrng support from the pic32mx cpu builds as pic32mx does not have hwrng only pic32mz does. --- boards/pic32-clicker/clicker.c | 4 ++++ boards/pic32-wifire/wifire.c | 6 ++++-- cpu/mips32r2_common/cpu.c | 8 ++++++++ cpu/mips_pic32_common/Makefile.include | 1 - cpu/mips_pic32mx/include/cpu.h | 5 +++++ cpu/mips_pic32mz/include/cpu.h | 5 +++++ 6 files changed, 26 insertions(+), 3 deletions(-) diff --git a/boards/pic32-clicker/clicker.c b/boards/pic32-clicker/clicker.c index f67273e860..1146ff79b2 100644 --- a/boards/pic32-clicker/clicker.c +++ b/boards/pic32-clicker/clicker.c @@ -13,6 +13,7 @@ #include "periph/uart.h" #include "bitarithm.h" #include "board.h" +#include "cpu.h" extern void dummy(void); @@ -36,6 +37,9 @@ void board_init(void) LED1_OFF; LED2_OFF; + /* initialize the CPU */ + cpu_init(); + /* Stop the linker from throwing away the PIC32 config register settings */ dummy(); } diff --git a/boards/pic32-wifire/wifire.c b/boards/pic32-wifire/wifire.c index e373a34249..9fe3b221a8 100644 --- a/boards/pic32-wifire/wifire.c +++ b/boards/pic32-wifire/wifire.c @@ -15,6 +15,7 @@ #include "periph/uart.h" #include "bitarithm.h" #include "board.h" +#include "cpu.h" extern void dummy(void); @@ -32,8 +33,6 @@ void board_init(void) uart_init(DEBUG_VIA_UART, DEBUG_UART_BAUD, NULL, 0); #endif - hwrng_init(); - /* Turn off all LED's */ gpio_init(LED1_PIN, GPIO_OUT); gpio_init(LED2_PIN, GPIO_OUT); @@ -44,6 +43,9 @@ void board_init(void) LED3_OFF; LED4_OFF; + /* initialize the CPU */ + cpu_init(); + /* Stop the linker from throwing away the PIC32 config register settings */ dummy(); } diff --git a/cpu/mips32r2_common/cpu.c b/cpu/mips32r2_common/cpu.c index 2cef4c9c40..d2483cbc1c 100644 --- a/cpu/mips32r2_common/cpu.c +++ b/cpu/mips32r2_common/cpu.c @@ -15,11 +15,13 @@ #include "periph/uart.h" #include "periph/timer.h" +#include "periph/init.h" #include "panic.h" #include "kernel_init.h" #include "cpu.h" #include "board.h" + void mips_start(void); extern void _fini(void); @@ -71,3 +73,9 @@ void panic_arch(void) while (1) { } } + +void cpu_init(void) +{ + /* trigger static peripheral initialization */ + periph_init(); +} diff --git a/cpu/mips_pic32_common/Makefile.include b/cpu/mips_pic32_common/Makefile.include index 7d26555c67..e0582db5dd 100644 --- a/cpu/mips_pic32_common/Makefile.include +++ b/cpu/mips_pic32_common/Makefile.include @@ -6,4 +6,3 @@ USEMODULE += mips_pic32_common USEMODULE += mips_pic32_common_periph USEMODULE += periph_common -USEMODULE += periph_hwrng diff --git a/cpu/mips_pic32mx/include/cpu.h b/cpu/mips_pic32mx/include/cpu.h index 45e64c4dbc..3ebc445ed4 100644 --- a/cpu/mips_pic32mx/include/cpu.h +++ b/cpu/mips_pic32mx/include/cpu.h @@ -47,6 +47,11 @@ static inline void cpu_print_last_instruction(void) /* This function must exist else RIOT won't compile */ } +/** + * @brief Initialize the CPU, set IRQ priorities + */ +void cpu_init(void); + #ifdef __cplusplus } #endif diff --git a/cpu/mips_pic32mz/include/cpu.h b/cpu/mips_pic32mz/include/cpu.h index e2ca23db66..963398c7ec 100644 --- a/cpu/mips_pic32mz/include/cpu.h +++ b/cpu/mips_pic32mz/include/cpu.h @@ -47,6 +47,11 @@ static inline void cpu_print_last_instruction(void) /* This function must exist else RIOT won't compile */ } +/** + * @brief Initialize the CPU, set IRQ priorities + */ +void cpu_init(void); + #ifdef __cplusplus } #endif -- GitLab