summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandroColomar <colomar.6.4.3@gmail.com>2019-01-17 04:39:53 +0100
committerAlejandroColomar <colomar.6.4.3@gmail.com>2019-01-17 04:39:53 +0100
commit68d684bfeb04b38d7c56ff54a61a89ab4858833a (patch)
tree85b5e11b219c7beaa57d520535065c7be9ca3c51
parent2d3860d3d47ee4121107785d6cc3dc65b95b442e (diff)
Improve configuration for compilation
-rw-r--r--Makefile4
-rwxr-xr-xsrc/actuators.c34
-rwxr-xr-xsrc/ctrl.c34
-rwxr-xr-xsrc/main.c64
4 files changed, 100 insertions, 36 deletions
diff --git a/Makefile b/Makefile
index f98ba88..41a78db 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
#!/usr/bin/make -f
VERSION = 1
-PATCHLEVEL = 3
+PATCHLEVEL = 4
SUBLEVEL = 0
-EXTRAVERSION =
+EXTRAVERSION = ~a1
NAME = little-bird
export VERSION
diff --git a/src/actuators.c b/src/actuators.c
index 680308c..463c5bd 100755
--- a/src/actuators.c
+++ b/src/actuators.c
@@ -40,11 +40,17 @@
/******************************************************************************
******* macros ***************************************************************
******************************************************************************/
+#define PROJECT_ACT_TASKING (PROJECT_ACT_IT)
/******************************************************************************
******* enums ****************************************************************
******************************************************************************/
+ enum Project_Act_Tasking {
+ PROJECT_ACT_DEL,
+ PROJECT_ACT_IT,
+ PROJECT_ACT_EV
+ };
/******************************************************************************
@@ -143,14 +149,18 @@ int proc_actuators (void)
}
}
- if (ACT_TASK_MODE_IT) {
+ switch (PROJECT_ACT_TASKING) {
+ case PROJECT_ACT_DEL:
if (proc_actuators_it()) {
return ERROR_NOK;
}
- } else {
+ break;
+ case PROJECT_ACT_IT:
+ case PROJECT_ACT_EV:
if (proc_actuators_delay()) {
return ERROR_NOK;
}
+ break;
}
return ERROR_OK;
@@ -176,8 +186,8 @@ static int modules_init (void)
goto err_servo;
}
- if (ACT_TASK_MODE_IT) {
- if (tim_timx_init(ACT_REFRESH_PERIOD_US)) {
+ if (PROJECT_ACT_TASKING != PROJECT_ACT_DEL) {
+ if (tim_it_init(ACT_REFRESH_PERIOD_US)) {
goto err_tim;
}
}
@@ -210,7 +220,7 @@ static int modules_deinit (void)
if (can_deinit()) {
status = ERROR_NOK;
}
- if (tim_timx_deinit()) {
+ if (tim_it_deinit()) {
status = ERROR_NOK;
}
if (delay_us_deinit()) {
@@ -226,17 +236,23 @@ static int proc_actuators_it (void)
{
while (true) {
-// __WFE();
- __WFI();
+ switch (PROJECT_ACT_TASKING) {
+ case PROJECT_ACT_IT:
+ __WFI();
+ break;
+ case PROJECT_ACT_EV:
+ __WFE();
+ break;
+ }
- if (tim_timx_interrupt) {
+ if (*tim_it_timx_interrupt_ptr) {
if (!proc_ref_read()) {
if (proc_actuators_set()) {
return ERROR_NOK;
}
}
- tim_timx_interrupt = false;
+ *tim_it_timx_interrupt_ptr = false;
} else if (button_interrupt) {
led_toggle();
diff --git a/src/ctrl.c b/src/ctrl.c
index 6f648a1..7f2f668 100755
--- a/src/ctrl.c
+++ b/src/ctrl.c
@@ -43,11 +43,17 @@
/******************************************************************************
******* macros ***************************************************************
******************************************************************************/
+#define PROJECT_CTRL_TASKING (PROJECT_CTRL_IT)
/******************************************************************************
******* enums ****************************************************************
******************************************************************************/
+ enum Project_Ctrl_Tasking {
+ PROJECT_CTRL_DEL,
+ PROJECT_CTRL_IT,
+ PROJECT_CTRL_EV
+ };
/******************************************************************************
@@ -149,14 +155,18 @@ int proc_ctrl (void)
}
}
- if (CTRL_TASK_MODE_IT) {
+ switch (PROJECT_CTRL_TASKING) {
+ case PROJECT_CTRL_DEL:
if (proc_ctrl_it()) {
return ERROR_NOK;
}
- } else {
+ break;
+ case PROJECT_CTRL_IT:
+ case PROJECT_CTRL_EV:
if (proc_ctrl_delay()) {
return ERROR_NOK;
}
+ break;
}
return ERROR_OK;
@@ -181,8 +191,8 @@ static int modules_init (void)
goto err_nunchuk;
}
- if (CTRL_TASK_MODE_IT) {
- if (tim_timx_init(CTRL_REFRESH_PERIOD_US)) {
+ if (PROJECT_CTRL_TASKING != PROJECT_CTRL_DEL) {
+ if (tim_it_init(CTRL_REFRESH_PERIOD_US)) {
goto err_tim;
}
}
@@ -214,7 +224,7 @@ static int modules_deinit (void)
if (can_deinit()) {
status = ERROR_NOK;
}
- if (tim_timx_deinit()) {
+ if (tim_it_deinit()) {
status = ERROR_NOK;
}
if (delay_us_deinit()) {
@@ -230,10 +240,16 @@ static int proc_ctrl_it (void)
{
while (true) {
- __WFE();
-// __WFI();
+ switch (PROJECT_CTRL_TASKING) {
+ case PROJECT_CTRL_IT:
+ __WFI();
+ break;
+ case PROJECT_CTRL_EV:
+ __WFE();
+ break;
+ }
- if (tim_timx_interrupt) {
+ if (*tim_it_timx_interrupt_ptr) {
if (proc_ctrl_read()) {
return ERROR_NOK;
}
@@ -241,7 +257,7 @@ static int proc_ctrl_it (void)
return ERROR_NOK;
}
- tim_timx_interrupt = false;
+ *tim_it_timx_interrupt_ptr = false;
}
}
}
diff --git a/src/main.c b/src/main.c
index 1f36a60..ba21ce0 100755
--- a/src/main.c
+++ b/src/main.c
@@ -48,15 +48,27 @@
/******************************************************************************
******* macros ***************************************************************
******************************************************************************/
- # define DEBUG_MODE (false)
+#define DEBUG_MODE (false)
- # define PROJECT_CTRL (false)
- # define PROJECT_ACT (!PROJECT_CTRL)
+#define PROJECT_SYSCLK_SOURCE (PROJECT_SYSCLK_FROM_PLL_MSI)
+
+#define PROJECT_COMPONENT (PROJECT_COMPONENT_CTRL)
/******************************************************************************
******* enums ****************************************************************
******************************************************************************/
+ enum Project_SysClk_Source {
+ PROJECT_SYSCLK_FROM_HSI,
+ PROJECT_SYSCLK_FROM_MSI,
+ PROJECT_SYSCLK_FROM_PLL_HSI,
+ PROJECT_SYSCLK_FROM_PLL_MSI
+ };
+
+ enum Project_Component {
+ PROJECT_COMPONENT_CTRL,
+ PROJECT_COMPONENT_ACT
+ };
/******************************************************************************
@@ -85,7 +97,22 @@ static noreturn void stuck_forever (bool led);
noreturn int main (void)
{
HAL_Init();
- sysclk_config();
+
+ switch (PROJECT_SYSCLK_SOURCE) {
+ case PROJECT_SYSCLK_FROM_HSI:
+ sysclk_config_hsi();
+ break;
+ case PROJECT_SYSCLK_FROM_MSI:
+ sysclk_config_msi();
+ break;
+ case PROJECT_SYSCLK_FROM_PLL_HSI:
+ sysclk_config_pll_hsi();
+ break;
+ case PROJECT_SYSCLK_FROM_PLL_MSI:
+ sysclk_config_pll_msi();
+ break;
+ }
+
prj_error = 0;
if (DEBUG_MODE) {
@@ -104,8 +131,8 @@ noreturn int main (void)
err:
-/* prj_error_handle();*/
- stuck_forever(true);
+ prj_error_handle();
+ stuck_forever(false);
}
@@ -115,14 +142,17 @@ err:
static int proc_init (void)
{
- if (PROJECT_ACT) {
- if (proc_actuators_init()) {
+ switch (PROJECT_COMPONENT) {
+ case PROJECT_COMPONENT_CTRL:
+ if (proc_ctrl_init()) {
return ERROR_NOK;
}
- } else if (PROJECT_CTRL) {
- if (proc_ctrl_init()) {
+ break;
+ case PROJECT_COMPONENT_ACT:
+ if (proc_actuators_init()) {
return ERROR_NOK;
}
+ break;
}
return ERROR_OK;
@@ -131,14 +161,17 @@ static int proc_init (void)
static int proc (void)
{
- if (PROJECT_ACT) {
- if (proc_actuators()) {
+ switch (PROJECT_COMPONENT) {
+ case PROJECT_COMPONENT_CTRL:
+ if (proc_ctrl()) {
return ERROR_NOK;
}
- } else if (PROJECT_CTRL) {
- if (proc_ctrl()) {
+ break;
+ case PROJECT_COMPONENT_ACT:
+ if (proc_actuators()) {
return ERROR_NOK;
}
+ break;
}
return ERROR_OK;
@@ -154,8 +187,7 @@ static noreturn void stuck_forever (bool led)
}
while (true) {
-// __WFI();
- __NOP();
+ __WFI();
}
}