From c3c8de0caddee187b33b68a9a9874122c3870c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20Hern=C3=A1ndez?= <shernand@iri.upc.edu> Date: Fri, 22 Jan 2016 22:18:00 +0000 Subject: [PATCH] Changed the main include. Added the USE_HAL_DRIVER macro. --- Makefile | 2 +- include/action.h | 2 +- include/action_id.h | 8 +++++++ include/adc_dma.h | 2 +- include/bioloid_dyn_master_sensors.h | 10 +++++++- include/bioloid_dyn_master_servos.h | 11 +++++++-- include/bioloid_dyn_slave.h | 3 +-- include/bioloid_gyro.h | 10 +++++++- include/bioloid_time.h | 2 +- include/eeprom.h | 10 +++++++- include/gpio.h | 2 +- include/motion_manager.h | 2 +- include/motion_pages.h | 2 +- include/zigbee.h | 2 +- src/motion_manager.c | 34 +++++++++++++--------------- 15 files changed, 69 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index 456e829..ec863f8 100755 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ DYNAMIXEL_PATH=../../STM32_processor/libraries/dynamixel_base BUILD_PATH=build COMPILE_OPTS = -mlittle-endian -mcpu=cortex-m4 -mthumb -mthumb-interwork -COMPILE_OPTS += -Wall -O2 -fno-common +COMPILE_OPTS += -Wall -O2 -fno-common -DUSE_HAL_DRIVER COMPILE_OPTS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 COMPILE_OPTS += -ffreestanding -nostdlib -D$(PROCESSOR_MACRO) -DARM_MATH_CM4 -D__FPU_PRESENT -DHSE_VALUE=8000000 INCLUDE_DIRS = -I$(HAL_PATH)/include -I$(HAL_PATH)/include/core -I$(HAL_PATH)/include/devices diff --git a/include/action.h b/include/action.h index 3a5dcb4..693ccc1 100644 --- a/include/action.h +++ b/include/action.h @@ -5,7 +5,7 @@ extern "C" { #endif -#include "stm32f4xx_hal.h" +#include "stm32f4xx.h" #include "motion_pages.h" extern int64_t action_current_angles[PAGE_MAX_NUM_SERVOS]; diff --git a/include/action_id.h b/include/action_id.h index bedb456..10c3628 100644 --- a/include/action_id.h +++ b/include/action_id.h @@ -1,6 +1,10 @@ #ifndef _ACTION_ID_H #define _ACTION_ID_H +#ifdef __cplusplus +extern "C" { +#endif + #define BOW 1 #define BRAVO 2 #define RAP_CHEST 5 @@ -137,4 +141,8 @@ #define BALANCE 224 #define CLAP_END 225 +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/adc_dma.h b/include/adc_dma.h index 35a7b0b..d360ab0 100644 --- a/include/adc_dma.h +++ b/include/adc_dma.h @@ -5,7 +5,7 @@ extern "C" { #endif -#include "stm32f4xx_hal.h" +#include "stm32f4xx.h" typedef enum {ADC_CH1,ADC_CH2,ADC_CH3,ADC_CH4,ADC_CH6,ADC_CH8} adc_ch_t; diff --git a/include/bioloid_dyn_master_sensors.h b/include/bioloid_dyn_master_sensors.h index db8a6c4..98554dc 100644 --- a/include/bioloid_dyn_master_sensors.h +++ b/include/bioloid_dyn_master_sensors.h @@ -1,12 +1,20 @@ #ifndef _BIOLOID_DYN_MASTER_SENSORS_H #define _BIOLOID_DYN_MASTER_SENSORS_H -#include "stm32f4xx_hal.h" +#ifdef __cplusplus +extern "C" { +#endif + +#include "stm32f4xx.h" #include "stm32_time.h" #include "dynamixel_master.h" #include "comm.h" void bioloid_dyn_master_sensors_init(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/bioloid_dyn_master_servos.h b/include/bioloid_dyn_master_servos.h index b512dd2..3152d56 100644 --- a/include/bioloid_dyn_master_servos.h +++ b/include/bioloid_dyn_master_servos.h @@ -1,8 +1,11 @@ #ifndef _BIOLOID_DYN_MASTER_SERVOS_H #define _BIOLOID_DYN_MASTER_SERVOS_H -#include "stm32f4xx_hal.h" -#include "stm32_time.h" +#ifdef __cplusplus +extern "C" { +#endif + +#include "stm32f4xx.h" #include "dynamixel_master.h" #include "comm.h" @@ -12,5 +15,9 @@ void bioloid_dyn_master_servos_init(void); inline void bioloid_dyn_master_servos_enable_power(void); inline void bioloid_dyn_master_servos_disable_power(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/bioloid_dyn_slave.h b/include/bioloid_dyn_slave.h index f6d7158..9ceda0a 100644 --- a/include/bioloid_dyn_slave.h +++ b/include/bioloid_dyn_slave.h @@ -5,8 +5,7 @@ extern "C" { #endif -#include "stm32f4xx_hal.h" -#include "stm32_time.h" +#include "stm32f4xx.h" #include "dynamixel_slave.h" #include "comm.h" diff --git a/include/bioloid_gyro.h b/include/bioloid_gyro.h index 6207496..2b7f999 100644 --- a/include/bioloid_gyro.h +++ b/include/bioloid_gyro.h @@ -1,7 +1,11 @@ #ifndef BIOLOID_GYRO_H #define BIOLOID_GYRO_H -#include "stm32f4xx_hal.h" +#ifdef __cplusplus +extern "C" { +#endif + +#include "stm32f4xx.h" #include "adc_dma.h" /* public functions */ @@ -15,4 +19,8 @@ uint8_t gyro_in_range(unsigned short int address, unsigned short int length); void gyro_process_read_cmd(unsigned short int address,unsigned short int length,unsigned char *data); void gyro_process_write_cmd(unsigned short int address,unsigned short int length,unsigned char *data); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/bioloid_time.h b/include/bioloid_time.h index 13ba01b..ccc113b 100755 --- a/include/bioloid_time.h +++ b/include/bioloid_time.h @@ -5,7 +5,7 @@ extern "C" { #endif -#include "stm32f4xx_hal.h" +#include "stm32f4xx.h" void bioloid_time_init(void); unsigned long long int bioloid_time_get_counts(void); diff --git a/include/eeprom.h b/include/eeprom.h index 25c5609..d1edf80 100755 --- a/include/eeprom.h +++ b/include/eeprom.h @@ -40,8 +40,12 @@ #ifndef __EEPROM_H #define __EEPROM_H +#ifdef __cplusplus +extern "C" { +#endif + /* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" +#include "stm32f4xx.h" /* Exported constants --------------------------------------------------------*/ /* Define the size of the sectors to be used */ @@ -88,6 +92,10 @@ uint16_t EE_Init(void); uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data); uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data); +#ifdef __cplusplus +} +#endif + #endif /* __EEPROM_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/include/gpio.h b/include/gpio.h index 76907b0..2cc86d3 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -5,7 +5,7 @@ extern "C" { #endif -#include "stm32f4xx_hal.h" +#include "stm32f4xx.h" typedef enum {USER1_LED,USER2_LED,RXD_LED,TXD_LED} led_t; diff --git a/include/motion_manager.h b/include/motion_manager.h index 3a1172a..e6a1616 100644 --- a/include/motion_manager.h +++ b/include/motion_manager.h @@ -5,7 +5,7 @@ extern "C" { #endif -#include "stm32f4xx_hal.h" +#include "stm32f4xx.h" typedef enum { R_SHOULDER_PITCH = 1, diff --git a/include/motion_pages.h b/include/motion_pages.h index 5ff494f..a195e17 100644 --- a/include/motion_pages.h +++ b/include/motion_pages.h @@ -5,7 +5,7 @@ extern "C" { #endif -#include "stm32f4xx_hal.h" +#include "stm32f4xx.h" #define MAX_PAGES 256 #define PAGE_MAX_NUM_SERVOS 31 diff --git a/include/zigbee.h b/include/zigbee.h index 87526c6..8672f7b 100644 --- a/include/zigbee.h +++ b/include/zigbee.h @@ -5,7 +5,7 @@ extern "C" { #endif -#include "stm32f4xx_hal.h" +#include "stm32f4xx.h" // public functions void zigbee_init(void); diff --git a/src/motion_manager.c b/src/motion_manager.c index 1c430c2..4370b17 100644 --- a/src/motion_manager.c +++ b/src/motion_manager.c @@ -184,7 +184,7 @@ void manager_init(uint16_t period_us) dyn_master_scan(&bioloid_dyn_master_servos,&num,servo_ids); ram_data[BIOLOID_MM_NUM_SERVOS]=num; manager_num_servos=0; - for(i=0;i<MANAGER_MAX_NUM_SERVOS;i++) +/* for(i=0;i<MANAGER_MAX_NUM_SERVOS;i++) { if(i==servo_ids[manager_num_servos]) { @@ -289,7 +289,7 @@ void manager_init(uint16_t period_us) manager_servos[i].ccw_angle_limit=0; } } - bioloid_dyn_master_servos_disable_power(); + bioloid_dyn_master_servos_disable_power();*/ /* configure timer */ ENABLE_MANAGER_TIMER_CLK; @@ -298,29 +298,27 @@ void manager_init(uint16_t period_us) MANAGER_TIM_Handle.Init.Prescaler = 84; MANAGER_TIM_Handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; MANAGER_TIM_Handle.Init.CounterMode = TIM_COUNTERMODE_UP; - HAL_NVIC_SetPriority(MANAGER_TIMER_IRQn, 2, 1); - HAL_NVIC_EnableIRQ(MANAGER_TIMER_IRQn); +// HAL_NVIC_SetPriority(MANAGER_TIMER_IRQn, 2, 1); +// HAL_NVIC_EnableIRQ(MANAGER_TIMER_IRQn); /* use the internal clock */ - sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; - HAL_TIM_ConfigClockSource(&MANAGER_TIM_Handle, &sClockSourceConfig); - HAL_TIM_OC_Init(&MANAGER_TIM_Handle); +// sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; +// HAL_TIM_ConfigClockSource(&MANAGER_TIM_Handle, &sClockSourceConfig); +// HAL_TIM_OC_Init(&MANAGER_TIM_Handle); /* disable master/slave mode */ - sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; - sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; - HAL_TIMEx_MasterConfigSynchronization(&MANAGER_TIM_Handle, &sMasterConfig); +// sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; +// sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; +// HAL_TIMEx_MasterConfigSynchronization(&MANAGER_TIM_Handle, &sMasterConfig); /* configure ouptut counter channel 4 */ - manager_motion_period=(period_us*1000000)>>16; - manager_motion_period_us=period_us; +// manager_motion_period=(period_us*1000000)>>16; +// manager_motion_period_us=period_us; /* initialize balance parameters */ - for(i=0;i<MANAGER_MAX_NUM_SERVOS;i++) - manager_balance_offset[i]=0; - manager_balance_enabled=0x00; +// for(i=0;i<MANAGER_MAX_NUM_SERVOS;i++) +// manager_balance_offset[i]=0; +// manager_balance_enabled=0x00; /* initialize action module */ - action_init(period_us); - - gpio_blink_led(RXD_LED,1000); +// action_init(period_us); } uint16_t manager_get_period(void) -- GitLab