From 605d8ef6c1b6ac75f4c2fa27f5c3310919644766 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Mon, 18 Feb 2013 16:08:47 +0900 Subject: [PATCH] more update to newer chibios --- ChangeLog | 7 ++++++- boards/CQ_STARM/board.c | 9 ++++----- boards/CQ_STARM/board.h | 10 ++++++++++ boards/CQ_STARM/mcuconf.h | 6 +++--- boards/FST_01_00/board.c | 9 ++++----- boards/FST_01_00/board.h | 15 ++++++++++++++- boards/FST_01_00/mcuconf.h | 7 +++---- boards/OLIMEX_STM32_H103/board.c | 9 ++++----- boards/OLIMEX_STM32_H103/board.h | 20 ++++++++++++++++++++ boards/OLIMEX_STM32_H103/mcuconf.h | 6 +++--- boards/STBEE/board.c | 10 ++++------ boards/STBEE/board.h | 23 ++++++++++++++++++++++- boards/STBEE/mcuconf.h | 6 +++--- boards/STBEE_MINI/board.c | 10 ++++------ boards/STBEE_MINI/board.h | 30 +++++++++++++++++++++++++++++- boards/STBEE_MINI/mcuconf.h | 6 +++--- src/adc_stm32f103.c | 2 +- 17 files changed, 137 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0623b2..01dd072 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,11 @@ * src/configure, src/gnuk.ld.in: Add MEMORY_SIZE. * src/ec_p256.c: Fix call of bn256_add_uint. * boards/STM8S_DISCOVERY/*: Update for ChibiOS/RT 2.4.x. + * boards/CQ_STARM/*: Likewise. + * boards/FST_01_00/*: Likewise. + * boards/OLIMEX_STM32_H103/*: Likewise. + * boards/STBEE/*: Likewise. + * boards/STBEE_MINI/*: Likewise. Merge ec_p256 branch. * src/Makefile.in: Add ECC files. @@ -32,7 +37,7 @@ * boards/common/board-common.c: Rename from hwinit.c. * src/usb_stm32f103.c: Rename from usb_lld.c. - * src/neug.h, src/neug.h: Update NeuG 0.05. + * src/neug.h, src/neug.c: Update NeuG 0.05. * src/adc_stm32f103.c, src/adc.h: New from NeuG 0.05. * src/random.c: Follow the change of NeuG 0.05. diff --git a/boards/CQ_STARM/board.c b/boards/CQ_STARM/board.c index c079a0c..950af29 100644 --- a/boards/CQ_STARM/board.c +++ b/boards/CQ_STARM/board.c @@ -2,10 +2,9 @@ #include "ch.h" #include "hal.h" -#include "../common/hwinit.c" - -void -hwinit1 (void) +/* + * Board-specific initialization code. + */ +void boardInit(void) { - hwinit1_common (); } diff --git a/boards/CQ_STARM/board.h b/boards/CQ_STARM/board.h index 5268912..2b20aae 100644 --- a/boards/CQ_STARM/board.h +++ b/boards/CQ_STARM/board.h @@ -150,4 +150,14 @@ #define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */ #define VAL_GPIOEODR 0xFFFFFFFF +#if !defined(_FROM_ASM_) +#ifdef __cplusplus +extern "C" { +#endif + void boardInit(void); +#ifdef __cplusplus +} +#endif +#endif /* _FROM_ASM_ */ + #endif /* _BOARD_H_ */ diff --git a/boards/CQ_STARM/mcuconf.h b/boards/CQ_STARM/mcuconf.h index 9b670b0..8bbd4e0 100644 --- a/boards/CQ_STARM/mcuconf.h +++ b/boards/CQ_STARM/mcuconf.h @@ -7,8 +7,8 @@ #define STM32_PLLMUL_VALUE 9 #define STM32_HPRE STM32_HPRE_DIV1 #define STM32_PPRE1 STM32_PPRE1_DIV2 -#define STM32_PPRE2 STM32_PPRE2_DIV2 -#define STM32_ADCPRE STM32_ADCPRE_DIV4 -#define STM32_MCO STM32_MCO_NOCLOCK +#define STM32_PPRE2 STM32_PPRE2_DIV1 +#define STM32_ADCPRE STM32_ADCPRE_DIV6 +#define STM32_RTCSEL STM32_RTCSEL_NOCLOCK #include "mcuconf-common.h" diff --git a/boards/FST_01_00/board.c b/boards/FST_01_00/board.c index c079a0c..950af29 100644 --- a/boards/FST_01_00/board.c +++ b/boards/FST_01_00/board.c @@ -2,10 +2,9 @@ #include "ch.h" #include "hal.h" -#include "../common/hwinit.c" - -void -hwinit1 (void) +/* + * Board-specific initialization code. + */ +void boardInit(void) { - hwinit1_common (); } diff --git a/boards/FST_01_00/board.h b/boards/FST_01_00/board.h index 5428bcf..45a88f6 100644 --- a/boards/FST_01_00/board.h +++ b/boards/FST_01_00/board.h @@ -37,6 +37,8 @@ #define GPIO_LED GPIOA_LED #define IOPORT_LED GPIOA +/* NeuG settings for ADC2 is default. */ + /* * Board identifier. */ @@ -54,7 +56,6 @@ * native STM32 HAL. */ #define STM32F10X_MD -#define CPU_WITH_NO_GPIOE 1 /* * IO pins assignments. @@ -88,6 +89,8 @@ /* * Port A setup. + * PA0 - Digital input with PullUp. AN0 + * PA1 - Digital input with PullUp. AN1 * PA11 - input with pull-up (USBDM) * PA12 - input with pull-up (USBDP) * Everything input with pull-up except: @@ -132,4 +135,14 @@ #define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */ #define VAL_GPIOEODR 0xFFFFFFFF +#if !defined(_FROM_ASM_) +#ifdef __cplusplus +extern "C" { +#endif + void boardInit(void); +#ifdef __cplusplus +} +#endif +#endif /* _FROM_ASM_ */ + #endif /* _BOARD_H_ */ diff --git a/boards/FST_01_00/mcuconf.h b/boards/FST_01_00/mcuconf.h index acfb005..8bbd4e0 100644 --- a/boards/FST_01_00/mcuconf.h +++ b/boards/FST_01_00/mcuconf.h @@ -7,9 +7,8 @@ #define STM32_PLLMUL_VALUE 9 #define STM32_HPRE STM32_HPRE_DIV1 #define STM32_PPRE1 STM32_PPRE1_DIV2 -#define STM32_PPRE2 STM32_PPRE2_DIV2 -#define STM32_ADCPRE STM32_ADCPRE_DIV4 -#define STM32_USBPRE STM32_USBPRE_DIV1P5 -#define STM32_MCO STM32_MCO_NOCLOCK +#define STM32_PPRE2 STM32_PPRE2_DIV1 +#define STM32_ADCPRE STM32_ADCPRE_DIV6 +#define STM32_RTCSEL STM32_RTCSEL_NOCLOCK #include "mcuconf-common.h" diff --git a/boards/OLIMEX_STM32_H103/board.c b/boards/OLIMEX_STM32_H103/board.c index c079a0c..950af29 100644 --- a/boards/OLIMEX_STM32_H103/board.c +++ b/boards/OLIMEX_STM32_H103/board.c @@ -2,10 +2,9 @@ #include "ch.h" #include "hal.h" -#include "../common/hwinit.c" - -void -hwinit1 (void) +/* + * Board-specific initialization code. + */ +void boardInit(void) { - hwinit1_common (); } diff --git a/boards/OLIMEX_STM32_H103/board.h b/boards/OLIMEX_STM32_H103/board.h index a6c2d84..e033d9f 100644 --- a/boards/OLIMEX_STM32_H103/board.h +++ b/boards/OLIMEX_STM32_H103/board.h @@ -37,6 +37,14 @@ #define GPIO_LED GPIOC_LED #define IOPORT_LED GPIOC +/* NeuG settings for ADC2. */ +#define NEUG_ADC_SETTING2_SMPR1 ADC_SMPR1_SMP_AN10(ADC_SAMPLE_1P5) \ + | ADC_SMPR1_SMP_AN11(ADC_SAMPLE_1P5) +#define NEUG_ADC_SETTING2_SMPR2 0 +#define NEUG_ADC_SETTING2_SQR3 ADC_SQR3_SQ1_N(ADC_CHANNEL_IN10) \ + | ADC_SQR3_SQ2_N(ADC_CHANNEL_IN11) +#define NEUG_ADC_SETTING2_NUM_CHANNELS 2 + /* * Board identifier. */ @@ -117,6 +125,8 @@ /* * Port C setup. + * PC0 - Digital input with PullUp. AN10 for NeuG + * PC1 - Digital input with PullUp. AN11 for NeuG * Everything input with pull-up except: * PC6 - Normal input because there is an external resistor. * PC7 - Normal input because there is an external resistor. @@ -145,4 +155,14 @@ #define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */ #define VAL_GPIOEODR 0xFFFFFFFF +#if !defined(_FROM_ASM_) +#ifdef __cplusplus +extern "C" { +#endif + void boardInit(void); +#ifdef __cplusplus +} +#endif +#endif /* _FROM_ASM_ */ + #endif /* _BOARD_H_ */ diff --git a/boards/OLIMEX_STM32_H103/mcuconf.h b/boards/OLIMEX_STM32_H103/mcuconf.h index 9b670b0..8bbd4e0 100644 --- a/boards/OLIMEX_STM32_H103/mcuconf.h +++ b/boards/OLIMEX_STM32_H103/mcuconf.h @@ -7,8 +7,8 @@ #define STM32_PLLMUL_VALUE 9 #define STM32_HPRE STM32_HPRE_DIV1 #define STM32_PPRE1 STM32_PPRE1_DIV2 -#define STM32_PPRE2 STM32_PPRE2_DIV2 -#define STM32_ADCPRE STM32_ADCPRE_DIV4 -#define STM32_MCO STM32_MCO_NOCLOCK +#define STM32_PPRE2 STM32_PPRE2_DIV1 +#define STM32_ADCPRE STM32_ADCPRE_DIV6 +#define STM32_RTCSEL STM32_RTCSEL_NOCLOCK #include "mcuconf-common.h" diff --git a/boards/STBEE/board.c b/boards/STBEE/board.c index efbbb79..76d6f7b 100644 --- a/boards/STBEE/board.c +++ b/boards/STBEE/board.c @@ -2,13 +2,11 @@ #include "ch.h" #include "hal.h" -#include "../common/hwinit.c" - -void -hwinit1 (void) +/* + * Board-specific initialization code. + */ +void boardInit(void) { - hwinit1_common (); - #if defined(PINPAD_CIR_SUPPORT) /* EXTI0 <= PB0 */ AFIO->EXTICR[0] = AFIO_EXTICR1_EXTI0_PB; diff --git a/boards/STBEE/board.h b/boards/STBEE/board.h index 75a3f41..25b446d 100644 --- a/boards/STBEE/board.h +++ b/boards/STBEE/board.h @@ -38,6 +38,14 @@ #define GPIO_LED GPIOD_LED1 #define IOPORT_LED GPIOD +/* NeuG settings for ADC2. */ +#define NEUG_ADC_SETTING2_SMPR1 ADC_SMPR1_SMP_AN10(ADC_SAMPLE_1P5) \ + | ADC_SMPR1_SMP_AN11(ADC_SAMPLE_1P5) +#define NEUG_ADC_SETTING2_SMPR2 0 +#define NEUG_ADC_SETTING2_SQR3 ADC_SQR3_SQ1_N(ADC_CHANNEL_IN10) \ + | ADC_SQR3_SQ2_N(ADC_CHANNEL_IN11) +#define NEUG_ADC_SETTING2_NUM_CHANNELS 2 + /* * Board identifier. */ @@ -148,6 +156,8 @@ /* * Port C setup. + * PC0 - Digital input with PullUp. AN10 for NeuG + * PC1 - Digital input with PullUp. AN11 for NeuG * Everything input with pull-up except: */ #define VAL_GPIOCCRL 0x88888888 /* PC7...PC0 */ @@ -157,7 +167,7 @@ /* * Port D setup. * Everything input with pull-up except: - * PD3 - Push pull output (USB ENABLE 1:DISABLE 0:ENABLE) 2MHz + * PD3 - Push pull output (USB_DISC 1:USB-DISABLE 0:USB-ENABLE) 2MHz * PD4 - Open Drain output 2MHz (LED1). */ #define VAL_GPIODCRL 0x88862888 /* PD7...PD0 */ @@ -187,4 +197,15 @@ #define VAL_GPIOGCRL 0x88888888 /* PG7...PG0 */ #define VAL_GPIOGCRH 0x88888888 /* PG15...PG8 */ #define VAL_GPIOGODR 0xFFFFFFFF + +#if !defined(_FROM_ASM_) +#ifdef __cplusplus +extern "C" { +#endif + void boardInit(void); +#ifdef __cplusplus +} +#endif +#endif /* _FROM_ASM_ */ + #endif /* _BOARD_H_ */ diff --git a/boards/STBEE/mcuconf.h b/boards/STBEE/mcuconf.h index 6b90b26..103aace 100644 --- a/boards/STBEE/mcuconf.h +++ b/boards/STBEE/mcuconf.h @@ -7,8 +7,8 @@ #define STM32_PLLMUL_VALUE 6 #define STM32_HPRE STM32_HPRE_DIV1 #define STM32_PPRE1 STM32_PPRE1_DIV2 -#define STM32_PPRE2 STM32_PPRE2_DIV2 -#define STM32_ADCPRE STM32_ADCPRE_DIV4 -#define STM32_MCO STM32_MCO_NOCLOCK +#define STM32_PPRE2 STM32_PPRE2_DIV1 +#define STM32_ADCPRE STM32_ADCPRE_DIV6 +#define STM32_RTCSEL STM32_RTCSEL_NOCLOCK #include "mcuconf-common.h" diff --git a/boards/STBEE_MINI/board.c b/boards/STBEE_MINI/board.c index c51d347..8bfa413 100644 --- a/boards/STBEE_MINI/board.c +++ b/boards/STBEE_MINI/board.c @@ -2,13 +2,11 @@ #include "ch.h" #include "hal.h" -#include "../common/hwinit.c" - -void -hwinit1 (void) +/* + * Board-specific initialization code. + */ +void boardInit(void) { - hwinit1_common (); - #if !defined(DFU_SUPPORT) if (palReadPad (IOPORT3, GPIOC_BUTTON) == 0) /* diff --git a/boards/STBEE_MINI/board.h b/boards/STBEE_MINI/board.h index da3adae..6e7c532 100644 --- a/boards/STBEE_MINI/board.h +++ b/boards/STBEE_MINI/board.h @@ -38,12 +38,18 @@ #define GPIO_LED GPIOA_LED1 #define IOPORT_LED GPIOA +#define NEUG_ADC_SETTING2_SMPR1 0 +#define NEUG_ADC_SETTING2_SMPR2 ADC_SMPR2_SMP_AN1(ADC_SAMPLE_1P5) \ + | ADC_SMPR2_SMP_AN2(ADC_SAMPLE_1P5) +#define NEUG_ADC_SETTING2_SQR3 ADC_SQR3_SQ1_N(ADC_CHANNEL_IN1) \ + | ADC_SQR3_SQ2_N(ADC_CHANNEL_IN2) +#define NEUG_ADC_SETTING2_NUM_CHANNELS 2 + /* * Board identifier. */ #define BOARD_STBEE_MINI #define BOARD_NAME "STBee Mini" -#define CPU_WITH_NO_GPIOE 1 #if defined(PINPAD_CIR_SUPPORT) || defined(PINPAD_DIAL_SUPPORT) #define HAVE_7SEGLED 1 @@ -101,6 +107,8 @@ #if defined(PINPAD_CIR_SUPPORT) || defined(PINPAD_DIAL_SUPPORT) /* * Port A setup. + * PA1 - Digital input with PullUp. AN1 for NeuG + * PA2 - Digital input with PullUp. AN2 for NeuG * PA6 - (TIM3_CH1) input with pull-up * PA7 - (TIM3_CH2) input with pull-down * PA11 - input with pull-up (USBDM) @@ -135,6 +143,8 @@ #else /* * Port A setup. + * PA1 - Digital input with PullUp. AN1 for NeuG + * PA2 - Digital input with PullUp. AN2 for NeuG * PA11 - input with pull-up (USBDM) * PA12 - input with pull-up (USBDP) * Everything input with pull-up except: @@ -174,4 +184,22 @@ #define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */ #define VAL_GPIODODR 0xFFFFFFFF +/* + * Port E setup. + * Everything input with pull-up except: + */ +#define VAL_GPIOECRL 0x88888888 /* PE7...PE0 */ +#define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */ +#define VAL_GPIOEODR 0xFFFFFFFF + +#if !defined(_FROM_ASM_) +#ifdef __cplusplus +extern "C" { +#endif + void boardInit(void); +#ifdef __cplusplus +} +#endif +#endif /* _FROM_ASM_ */ + #endif /* _BOARD_H_ */ diff --git a/boards/STBEE_MINI/mcuconf.h b/boards/STBEE_MINI/mcuconf.h index 6b90b26..103aace 100644 --- a/boards/STBEE_MINI/mcuconf.h +++ b/boards/STBEE_MINI/mcuconf.h @@ -7,8 +7,8 @@ #define STM32_PLLMUL_VALUE 6 #define STM32_HPRE STM32_HPRE_DIV1 #define STM32_PPRE1 STM32_PPRE1_DIV2 -#define STM32_PPRE2 STM32_PPRE2_DIV2 -#define STM32_ADCPRE STM32_ADCPRE_DIV4 -#define STM32_MCO STM32_MCO_NOCLOCK +#define STM32_PPRE2 STM32_PPRE2_DIV1 +#define STM32_ADCPRE STM32_ADCPRE_DIV6 +#define STM32_RTCSEL STM32_RTCSEL_NOCLOCK #include "mcuconf-common.h" diff --git a/src/adc_stm32f103.c b/src/adc_stm32f103.c index d8cd2d7..8566968 100644 --- a/src/adc_stm32f103.c +++ b/src/adc_stm32f103.c @@ -54,8 +54,8 @@ #define ADC_CHANNEL_IN0 0 #define ADC_CHANNEL_IN1 1 -#define ADC_CHANNEL_IN9 9 #define ADC_CHANNEL_IN2 2 +#define ADC_CHANNEL_IN9 9 #define ADC_CHANNEL_IN10 10 #define ADC_CHANNEL_IN11 11 #define ADC_CHANNEL_SENSOR 16