Formatting fixes for libperipherals

This commit is contained in:
e.gavrin
2014-08-12 00:15:13 +04:00
parent 839ad7e4b4
commit 0510b66504
6 changed files with 68 additions and 77 deletions
+15 -11
View File
@@ -35,7 +35,7 @@ led_toggle (uint32_t led_id)
#ifdef __TARGET_MCU #ifdef __TARGET_MCU
GPIOD->ODR ^= (uint16_t) (1 << led_id); GPIOD->ODR ^= (uint16_t) (1 << led_id);
#endif #endif
} }
@@ -48,7 +48,7 @@ led_on (uint32_t led_id)
#ifdef __TARGET_MCU #ifdef __TARGET_MCU
GPIO_WriteBit(GPIOD, (uint16_t) (1 << led_id), Bit_SET); GPIO_WriteBit (GPIOD, (uint16_t) (1 << led_id), Bit_SET);
#endif #endif
} }
@@ -60,7 +60,7 @@ led_off (uint32_t led_id)
#endif #endif
#ifdef __TARGET_MCU #ifdef __TARGET_MCU
GPIO_WriteBit(GPIOD, (uint16_t) (1 << led_id), Bit_RESET); GPIO_WriteBit (GPIOD, (uint16_t) (1 << led_id), Bit_RESET);
#endif #endif
} }
@@ -81,16 +81,20 @@ led_blink_once (uint32_t led_id)
} }
#ifdef __TARGET_MCU #ifdef __TARGET_MCU
void initialize_leds()
void
initialize_leds ()
{ {
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOD, ENABLE);
GPIO_InitTypeDef gpioStructure; GPIO_InitTypeDef gpioStructure;
gpioStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; gpioStructure.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;
gpioStructure.GPIO_Mode = GPIO_Mode_OUT; gpioStructure.GPIO_Mode = GPIO_Mode_OUT;
gpioStructure.GPIO_Speed = GPIO_Speed_100MHz; gpioStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_Init(GPIOD, &gpioStructure); 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 #endif
+7 -7
View File
@@ -14,18 +14,18 @@
*/ */
#ifndef ACTUATORS_H #ifndef ACTUATORS_H
#define ACTUATORS_H #define ACTUATORS_H
#include "globals.h" #include "globals.h"
void led_toggle(uint32_t); void led_toggle (uint32_t);
void led_on(uint32_t); void led_on (uint32_t);
void led_off(uint32_t); void led_off (uint32_t);
void led_blink_once(uint32_t); void led_blink_once (uint32_t);
#ifdef __TARGET_MCU #ifdef __TARGET_MCU
void initialize_leds(void); void initialize_leds (void);
#endif #endif
#endif /* ACTUATORS_H */ #endif /* ACTUATORS_H */
+28 -39
View File
@@ -17,7 +17,6 @@
#include "jerry-libc.h" #include "jerry-libc.h"
#ifdef __TARGET_MCU #ifdef __TARGET_MCU
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic" #pragma GCC diagnostic ignored "-Wpedantic"
#pragma GCC diagnostic ignored "-Wsign-conversion" #pragma GCC diagnostic ignored "-Wsign-conversion"
@@ -30,7 +29,6 @@
#define LED_ORANGE 13 #define LED_ORANGE 13
#define LED_RED 14 #define LED_RED 14
#define LED_BLUE 15 #define LED_BLUE 15
#endif #endif
int int
@@ -64,15 +62,10 @@ wait_ms (uint32_t time_ms)
// 1 millisecond = 1,000,000 Nanoseconds // 1 millisecond = 1,000,000 Nanoseconds
#define NANO_SECOND_MULTIPLIER 1000000 #define NANO_SECOND_MULTIPLIER 1000000
__printf ("wait_ms: %d\n", time_ms); __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 #endif
#ifdef __TARGET_MCU #ifdef __TARGET_MCU
while (time_ms--) while (time_ms --)
{ {
wait_1ms (); wait_1ms ();
} }
@@ -81,18 +74,19 @@ wait_ms (uint32_t time_ms)
#ifdef __TARGET_MCU #ifdef __TARGET_MCU
void initialize_timer() void
initialize_timer ()
{ {
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM2, ENABLE);
TIM_TimeBaseInitTypeDef timerInitStructure; TIM_TimeBaseInitTypeDef timerInitStructure;
timerInitStructure.TIM_Prescaler = 40000; timerInitStructure.TIM_Prescaler = 40000;
timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up; timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
timerInitStructure.TIM_Period = 500; timerInitStructure.TIM_Period = 500;
timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1; timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
timerInitStructure.TIM_RepetitionCounter = 0; timerInitStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM2, &timerInitStructure); TIM_TimeBaseInit (TIM2, &timerInitStructure);
TIM_Cmd(TIM2, ENABLE); TIM_Cmd (TIM2, ENABLE);
} }
void void
@@ -104,27 +98,20 @@ fake_exit (void)
int dot = 600000; int dot = 600000;
int dash = dot * 3; int dash = dot * 3;
while (1) 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);
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); for ( index = 0; index < dot; 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->BSRRH = (uint16_t) (1 << pin);
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); 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++);
} }
} }
static __IO uint32_t sys_tick_counter; static __IO uint32_t sys_tick_counter;
void void
@@ -142,19 +129,21 @@ initialize_sys_tick (void)
} }
void void
set_sys_tick_counter(uint32_t set_value) set_sys_tick_counter (uint32_t set_value)
{ {
sys_tick_counter = set_value; sys_tick_counter = set_value;
} }
uint32_t uint32_t
get_sys_tick_counter(void) get_sys_tick_counter (void)
{ {
return sys_tick_counter; return sys_tick_counter;
} }
void SysTick_Handler(void) { void
time_tick_decrement(); SysTick_Handler (void)
{
time_tick_decrement ();
} }
void void
@@ -162,7 +151,7 @@ time_tick_decrement (void)
{ {
if (sys_tick_counter != 0x00) if (sys_tick_counter != 0x00)
{ {
sys_tick_counter--; sys_tick_counter --;
} }
} }
+15 -16
View File
@@ -14,32 +14,31 @@
*/ */
#ifndef COMMON_IO_H #ifndef COMMON_IO_H
#define COMMON_IO_H #define COMMON_IO_H
#include "globals.h" #include "globals.h"
int digital_read(uint32_t, uint32_t); int digital_read (uint32_t, uint32_t);
void digital_write(uint32_t, uint32_t); void digital_write (uint32_t, uint32_t);
int analog_read(uint32_t, uint32_t); int analog_read (uint32_t, uint32_t);
void analog_write(uint32_t, uint32_t); void analog_write (uint32_t, uint32_t);
void wait_ms(uint32_t);
void wait_ms (uint32_t);
#ifdef __TARGET_MCU #ifdef __TARGET_MCU
void fake_exit(void); void fake_exit (void);
void initialize_timer(void); void initialize_timer (void);
void initialize_sys_tick(void); void initialize_sys_tick (void);
void SysTick_Handler(void); void SysTick_Handler (void);
void time_tick_decrement(void); void time_tick_decrement (void);
void wait_1ms(void); void wait_1ms (void);
void set_sys_tick_counter(uint32_t); void set_sys_tick_counter (uint32_t);
uint32_t get_sys_tick_counter(void); uint32_t get_sys_tick_counter (void);
#endif #endif
#endif /* COMMON_IO_H */ #endif /* COMMON_IO_H */
+1 -1
View File
@@ -13,4 +13,4 @@
* limitations under the License. * limitations under the License.
*/ */
#include "sensors.h" #include "sensors.h"
+2 -3
View File
@@ -14,9 +14,8 @@
*/ */
#ifndef SENSORS_H #ifndef SENSORS_H
#define SENSORS_H #define SENSORS_H
#include "globals.h" #include "globals.h"
#endif /* SENSORS_H */ #endif /* SENSORS_H */