diff --git a/src/libperipherals/actuators.c b/src/libperipherals/actuators.c index 4faffc3d8..39d271e72 100644 --- a/src/libperipherals/actuators.c +++ b/src/libperipherals/actuators.c @@ -35,7 +35,7 @@ led_toggle (uint32_t led_id) #ifdef __TARGET_MCU - GPIOD->ODR ^= (uint16_t) (1 << led_id); + GPIOD->ODR ^= (uint16_t) (1 << led_id); #endif } @@ -48,7 +48,7 @@ led_on (uint32_t led_id) #ifdef __TARGET_MCU - GPIO_WriteBit(GPIOD, (uint16_t) (1 << led_id), Bit_SET); + GPIO_WriteBit (GPIOD, (uint16_t) (1 << led_id), Bit_SET); #endif } @@ -60,7 +60,7 @@ led_off (uint32_t led_id) #endif #ifdef __TARGET_MCU - GPIO_WriteBit(GPIOD, (uint16_t) (1 << led_id), Bit_RESET); + GPIO_WriteBit (GPIOD, (uint16_t) (1 << led_id), Bit_RESET); #endif } @@ -81,16 +81,20 @@ led_blink_once (uint32_t led_id) } #ifdef __TARGET_MCU -void initialize_leds() + +void +initialize_leds () { - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); + RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOD, ENABLE); - GPIO_InitTypeDef gpioStructure; - gpioStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; - gpioStructure.GPIO_Mode = GPIO_Mode_OUT; - gpioStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_Init(GPIOD, &gpioStructure); + GPIO_InitTypeDef gpioStructure; + gpioStructure.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15; + gpioStructure.GPIO_Mode = GPIO_Mode_OUT; + gpioStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_Init (GPIOD, &gpioStructure); - GPIO_WriteBit(GPIOD, GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15, Bit_RESET); + GPIO_WriteBit (GPIOD, + GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;, + Bit_RESET); } #endif diff --git a/src/libperipherals/actuators.h b/src/libperipherals/actuators.h index 2e15ec4aa..989e875df 100644 --- a/src/libperipherals/actuators.h +++ b/src/libperipherals/actuators.h @@ -14,18 +14,18 @@ */ #ifndef ACTUATORS_H -#define ACTUATORS_H +#define ACTUATORS_H #include "globals.h" -void led_toggle(uint32_t); -void led_on(uint32_t); -void led_off(uint32_t); -void led_blink_once(uint32_t); +void led_toggle (uint32_t); +void led_on (uint32_t); +void led_off (uint32_t); +void led_blink_once (uint32_t); #ifdef __TARGET_MCU -void initialize_leds(void); +void initialize_leds (void); #endif -#endif /* ACTUATORS_H */ +#endif /* ACTUATORS_H */ diff --git a/src/libperipherals/common-io.c b/src/libperipherals/common-io.c index d52c45dab..b818def2a 100644 --- a/src/libperipherals/common-io.c +++ b/src/libperipherals/common-io.c @@ -17,7 +17,6 @@ #include "jerry-libc.h" #ifdef __TARGET_MCU - #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" #pragma GCC diagnostic ignored "-Wsign-conversion" @@ -30,7 +29,6 @@ #define LED_ORANGE 13 #define LED_RED 14 #define LED_BLUE 15 - #endif int @@ -64,15 +62,10 @@ wait_ms (uint32_t time_ms) // 1 millisecond = 1,000,000 Nanoseconds #define NANO_SECOND_MULTIPLIER 1000000 __printf ("wait_ms: %d\n", time_ms); - // const long interval_ms = time_ms * NANO_SECOND_MULTIPLIER; - // - // timespec sleep_value = {0}; - // sleep_value.tv_nsec = interval_ms; - // nanosleep (&sleep_value, NULL); #endif #ifdef __TARGET_MCU - while (time_ms--) + while (time_ms --) { wait_1ms (); } @@ -81,18 +74,19 @@ wait_ms (uint32_t time_ms) #ifdef __TARGET_MCU -void initialize_timer() +void +initialize_timer () { - RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); + RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM2, ENABLE); - TIM_TimeBaseInitTypeDef timerInitStructure; - timerInitStructure.TIM_Prescaler = 40000; - timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up; - timerInitStructure.TIM_Period = 500; - timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1; - timerInitStructure.TIM_RepetitionCounter = 0; - TIM_TimeBaseInit(TIM2, &timerInitStructure); - TIM_Cmd(TIM2, ENABLE); + TIM_TimeBaseInitTypeDef timerInitStructure; + timerInitStructure.TIM_Prescaler = 40000; + timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up; + timerInitStructure.TIM_Period = 500; + timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1; + timerInitStructure.TIM_RepetitionCounter = 0; + TIM_TimeBaseInit (TIM2, &timerInitStructure); + TIM_Cmd (TIM2, ENABLE); } void @@ -104,27 +98,20 @@ fake_exit (void) int dot = 600000; int dash = dot * 3; - + while (1) { - gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); - gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); - gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); - - gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); - gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); - gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); - - gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); - gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); - gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); - - for (index = 0; index < dash * 7; index++); + gpio->BSRRL = (uint16_t) (1 << pin); + for ( index = 0; index < dot; index ++) + { + }; + gpio->BSRRH = (uint16_t) (1 << pin); + for (index = 0; index < dash; index ++) + { + }; } } - - static __IO uint32_t sys_tick_counter; void @@ -142,19 +129,21 @@ initialize_sys_tick (void) } void -set_sys_tick_counter(uint32_t set_value) +set_sys_tick_counter (uint32_t set_value) { sys_tick_counter = set_value; } uint32_t -get_sys_tick_counter(void) +get_sys_tick_counter (void) { return sys_tick_counter; } -void SysTick_Handler(void) { - time_tick_decrement(); +void +SysTick_Handler (void) +{ + time_tick_decrement (); } void @@ -162,7 +151,7 @@ time_tick_decrement (void) { if (sys_tick_counter != 0x00) { - sys_tick_counter--; + sys_tick_counter --; } } diff --git a/src/libperipherals/common-io.h b/src/libperipherals/common-io.h index 60abdf976..b581f98e7 100644 --- a/src/libperipherals/common-io.h +++ b/src/libperipherals/common-io.h @@ -14,32 +14,31 @@ */ #ifndef COMMON_IO_H -#define COMMON_IO_H +#define COMMON_IO_H #include "globals.h" -int digital_read(uint32_t, uint32_t); -void digital_write(uint32_t, uint32_t); +int digital_read (uint32_t, uint32_t); +void digital_write (uint32_t, uint32_t); -int analog_read(uint32_t, uint32_t); -void analog_write(uint32_t, uint32_t); - -void wait_ms(uint32_t); +int analog_read (uint32_t, uint32_t); +void analog_write (uint32_t, uint32_t); +void wait_ms (uint32_t); #ifdef __TARGET_MCU -void fake_exit(void); +void fake_exit (void); -void initialize_timer(void); -void initialize_sys_tick(void); -void SysTick_Handler(void); +void initialize_timer (void); +void initialize_sys_tick (void); +void SysTick_Handler (void); -void time_tick_decrement(void); -void wait_1ms(void); +void time_tick_decrement (void); +void wait_1ms (void); -void set_sys_tick_counter(uint32_t); -uint32_t get_sys_tick_counter(void); +void set_sys_tick_counter (uint32_t); +uint32_t get_sys_tick_counter (void); #endif -#endif /* COMMON_IO_H */ +#endif /* COMMON_IO_H */ diff --git a/src/libperipherals/sensors.c b/src/libperipherals/sensors.c index 1f5ea2f0d..cf9458f35 100644 --- a/src/libperipherals/sensors.c +++ b/src/libperipherals/sensors.c @@ -13,4 +13,4 @@ * limitations under the License. */ -#include "sensors.h" \ No newline at end of file +#include "sensors.h" diff --git a/src/libperipherals/sensors.h b/src/libperipherals/sensors.h index 3b6f5a45f..586ab0ff0 100644 --- a/src/libperipherals/sensors.h +++ b/src/libperipherals/sensors.h @@ -14,9 +14,8 @@ */ #ifndef SENSORS_H -#define SENSORS_H +#define SENSORS_H #include "globals.h" -#endif /* SENSORS_H */ - +#endif /* SENSORS_H */