From a0f69cb0bc4be17431849753c6f7b720cec7f6a5 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Thu, 14 May 2015 13:04:58 +0200 Subject: implement device id --- nuttx-configs/trifle/scripts/ld.script | 5 +++ src/drivers/boards/trifle/board_config.h | 4 +-- src/drivers/boards/trifle/devconfig.c | 52 -------------------------------- src/drivers/boards/trifle/idconfig.c | 8 +++++ src/drivers/boards/trifle/module.mk | 6 +++- src/drivers/boards/trifle/pwmconfig.c | 52 ++++++++++++++++++++++++++++++++ src/drivers/kinetis/drv_hrt.c | 2 -- 7 files changed, 72 insertions(+), 57 deletions(-) delete mode 100644 src/drivers/boards/trifle/devconfig.c create mode 100644 src/drivers/boards/trifle/idconfig.c create mode 100644 src/drivers/boards/trifle/pwmconfig.c diff --git a/nuttx-configs/trifle/scripts/ld.script b/nuttx-configs/trifle/scripts/ld.script index 23e6a5174..c721346f3 100755 --- a/nuttx-configs/trifle/scripts/ld.script +++ b/nuttx-configs/trifle/scripts/ld.script @@ -69,6 +69,11 @@ SECTIONS KEEP(*(.cfmconfig)) } > cfmprotect + .idconfig : { + __device_id = ABSOLUTE(.); + KEEP(*(.idconfig)) + } > progflash + .text : { _stext = ABSOLUTE(.); KEEP(*(.text .text.*)) diff --git a/src/drivers/boards/trifle/board_config.h b/src/drivers/boards/trifle/board_config.h index 5ebae1973..d860bb906 100644 --- a/src/drivers/boards/trifle/board_config.h +++ b/src/drivers/boards/trifle/board_config.h @@ -4,8 +4,8 @@ #include #include -//totally random -#define UDID_START 0x2000000 +extern uint32_t __device_id; +#define UDID_START __device_id #define GPIO_LED0 (PIN_PORTC | PIN5 | GPIO_HIGHDRIVE | GPIO_OUTPUT_ONE) diff --git a/src/drivers/boards/trifle/devconfig.c b/src/drivers/boards/trifle/devconfig.c deleted file mode 100644 index 1fec4acd6..000000000 --- a/src/drivers/boards/trifle/devconfig.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -__EXPORT const struct pwm_servo_timer pwm_servo_timers[PWM_SERVO_MAX_TIMERS] = { - { - .ftm_base = KINETIS_FTM0_BASE, - .scgc = KINETIS_SIM_SCGC6, - .scgc_enable = 1 << 24 - } -}; - -__EXPORT const struct pwm_servo_channel pwm_servo_channels[PWM_SERVO_MAX_CHANNELS] = { - { - .timer = &pwm_servo_timers[0], - .ftm_channel = 1, - .pinconfig = PIN_PORTC | PIN2 | PIN_ALT4_OUTPUT | PIN_ALT4_HIGHDRIVE - }, - { - .timer = &pwm_servo_timers[0], - .ftm_channel = 0, - .pinconfig = PIN_PORTC | PIN1 | PIN_ALT4_OUTPUT | PIN_ALT4_HIGHDRIVE - }, - { - .timer = &pwm_servo_timers[0], - .ftm_channel = 6, - .pinconfig = PIN_PORTD | PIN6 | PIN_ALT4_OUTPUT | PIN_ALT4_HIGHDRIVE - }, - { - .timer = &pwm_servo_timers[0], - .ftm_channel = 5, - .pinconfig = PIN_PORTD | PIN5 | PIN_ALT4_OUTPUT | PIN_ALT4_HIGHDRIVE - }, - { - .timer = &pwm_servo_timers[0], - .ftm_channel = 2, - .pinconfig = PIN_PORTC | PIN3 | PIN_ALT4_OUTPUT | PIN_ALT4_HIGHDRIVE - }, - { - .timer = &pwm_servo_timers[0], - .ftm_channel = 3, - .pinconfig = PIN_PORTC | PIN4 | PIN_ALT4_OUTPUT | PIN_ALT4_HIGHDRIVE - } -}; diff --git a/src/drivers/boards/trifle/idconfig.c b/src/drivers/boards/trifle/idconfig.c new file mode 100644 index 000000000..8fb80f987 --- /dev/null +++ b/src/drivers/boards/trifle/idconfig.c @@ -0,0 +1,8 @@ +#include + +__attribute__ ((section(".idconfig"))) +uint32_t device_id[] = { + 0xdeadbeef, + 0xdeadbeef, + 0xdeadbeef +}; diff --git a/src/drivers/boards/trifle/module.mk b/src/drivers/boards/trifle/module.mk index 7c4e4a525..6d553749a 100644 --- a/src/drivers/boards/trifle/module.mk +++ b/src/drivers/boards/trifle/module.mk @@ -2,6 +2,10 @@ # Board-specific startup code for the CONDOR # -SRCS = cfmconfig.c devconfig.c up_boot.c up_leds.c +SRCS = cfmconfig.c \ + pwmconfig.c \ + idconfig.c \ + up_boot.c \ + up_leds.c MAXOPTIMIZATION = -Os diff --git a/src/drivers/boards/trifle/pwmconfig.c b/src/drivers/boards/trifle/pwmconfig.c new file mode 100644 index 000000000..1fec4acd6 --- /dev/null +++ b/src/drivers/boards/trifle/pwmconfig.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +__EXPORT const struct pwm_servo_timer pwm_servo_timers[PWM_SERVO_MAX_TIMERS] = { + { + .ftm_base = KINETIS_FTM0_BASE, + .scgc = KINETIS_SIM_SCGC6, + .scgc_enable = 1 << 24 + } +}; + +__EXPORT const struct pwm_servo_channel pwm_servo_channels[PWM_SERVO_MAX_CHANNELS] = { + { + .timer = &pwm_servo_timers[0], + .ftm_channel = 1, + .pinconfig = PIN_PORTC | PIN2 | PIN_ALT4_OUTPUT | PIN_ALT4_HIGHDRIVE + }, + { + .timer = &pwm_servo_timers[0], + .ftm_channel = 0, + .pinconfig = PIN_PORTC | PIN1 | PIN_ALT4_OUTPUT | PIN_ALT4_HIGHDRIVE + }, + { + .timer = &pwm_servo_timers[0], + .ftm_channel = 6, + .pinconfig = PIN_PORTD | PIN6 | PIN_ALT4_OUTPUT | PIN_ALT4_HIGHDRIVE + }, + { + .timer = &pwm_servo_timers[0], + .ftm_channel = 5, + .pinconfig = PIN_PORTD | PIN5 | PIN_ALT4_OUTPUT | PIN_ALT4_HIGHDRIVE + }, + { + .timer = &pwm_servo_timers[0], + .ftm_channel = 2, + .pinconfig = PIN_PORTC | PIN3 | PIN_ALT4_OUTPUT | PIN_ALT4_HIGHDRIVE + }, + { + .timer = &pwm_servo_timers[0], + .ftm_channel = 3, + .pinconfig = PIN_PORTC | PIN4 | PIN_ALT4_OUTPUT | PIN_ALT4_HIGHDRIVE + } +}; diff --git a/src/drivers/kinetis/drv_hrt.c b/src/drivers/kinetis/drv_hrt.c index 90714b7ba..8a765c970 100644 --- a/src/drivers/kinetis/drv_hrt.c +++ b/src/drivers/kinetis/drv_hrt.c @@ -178,5 +178,3 @@ void hrt_init(void) { } - -__END_DECLS -- cgit v1.2.3