mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-05 23:49:00 +08:00
Converted the whole test_led lisa example and it's dependencies to libopencm3.
This commit is contained in:
+1
-1
@@ -154,7 +154,7 @@ else
|
||||
LDFLAGS += -D__thumb2__ -T$(LDSCRIPT) -nostartfiles -L$(GCC_LIB_DIR) -O$(OPT)
|
||||
endif
|
||||
LDFLAGS += -Wl,-Map=$(OBJDIR)/$(TARGET).map,--cref,--gc-sections
|
||||
LDLIBS += -lc -lm -lgcc -lcmsis -lstm32 -lopencm3_stm32f1
|
||||
LDLIBS += -lc -lm -lgcc -lopencm3_stm32f1
|
||||
|
||||
CPFLAGS = -j .isr_vector -j .text -j .data
|
||||
CPFLAGS_BIN = -Obinary
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#ifndef LED_HW_H
|
||||
#define LED_HW_H
|
||||
|
||||
#include <stm32/gpio.h>
|
||||
#include <stm32/rcc.h>
|
||||
#include <libopencm3/stm32/f1/gpio.h>
|
||||
#include <libopencm3/stm32/f1/rcc.h>
|
||||
|
||||
#include BOARD_CONFIG
|
||||
|
||||
@@ -50,19 +50,19 @@
|
||||
#define LED_AFIO_REMAP(i) _LED_AFIO_REMAP(LED_ ## i ## _AFIO_REMAP)
|
||||
|
||||
/* set pin as output */
|
||||
#define LED_INIT(i) { \
|
||||
GPIO_InitTypeDef GPIO_InitStructure; \
|
||||
RCC_APB2PeriphClockCmd(LED_GPIO_CLK(i), ENABLE); \
|
||||
GPIO_InitStructure.GPIO_Pin = LED_GPIO_PIN(i); \
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; \
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; \
|
||||
GPIO_Init(LED_GPIO(i), &GPIO_InitStructure); \
|
||||
LED_AFIO_REMAP(i); \
|
||||
}
|
||||
#define LED_INIT(i) { \
|
||||
rcc_peripheral_enable_clock(&RCC_APB2ENR, \
|
||||
LED_GPIO_CLK(i)); \
|
||||
gpio_set_mode(LED_GPIO(i), \
|
||||
GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, \
|
||||
LED_GPIO_PIN(i)); \
|
||||
LED_AFIO_REMAP(i); \
|
||||
}
|
||||
|
||||
#define LED_ON(i) {LED_GPIO(i)->BRR = LED_GPIO_PIN(i);}
|
||||
#define LED_OFF(i) { LED_GPIO(i)->BSRR = LED_GPIO_PIN(i);}
|
||||
#define LED_TOGGLE(i) { LED_GPIO(i)->ODR ^= LED_GPIO_PIN(i);}
|
||||
#define LED_ON(i) { GPIO_BRR(LED_GPIO(i)) = LED_GPIO_PIN(i);}
|
||||
#define LED_OFF(i) { GPIO_BSRR(LED_GPIO(i)) = LED_GPIO_PIN(i);}
|
||||
#define LED_TOGGLE(i) { GPIO_ODR(LED_GPIO(i)) ^= LED_GPIO_PIN(i);}
|
||||
|
||||
#define LED_PERIODIC() {}
|
||||
|
||||
@@ -80,17 +80,19 @@ extern uint8_t led_status[NB_LED];
|
||||
/* PC15 led_data */
|
||||
|
||||
#define LED_INIT(_i) { \
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); \
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); \
|
||||
GPIO_InitTypeDef GPIO_InitStructure; \
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; \
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; \
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; \
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure); \
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; \
|
||||
GPIO_Init(GPIOC, &GPIO_InitStructure); \
|
||||
for(uint8_t i=0; i<NB_LED; i++) \
|
||||
led_status[i] = FALSE; \
|
||||
rcc_peripheral_enable_clock(&RCC_APB2ENR, \
|
||||
RCC_APB2ENR_IOPAEN | \
|
||||
RCC_APB2ENR_IOPCEN); \
|
||||
gpio_set_mode(GPIOA, \
|
||||
GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, \
|
||||
GPIO8); \
|
||||
gpio_set_mode(GPIOC, \
|
||||
GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, \
|
||||
GPIO15); \
|
||||
for(uint8_t i=0; i<NB_LED; i++) \
|
||||
led_status[i] = FALSE; \
|
||||
}
|
||||
|
||||
#define LED_ON(i) { led_status[i] = TRUE; }
|
||||
@@ -98,15 +100,15 @@ extern uint8_t led_status[NB_LED];
|
||||
#define LED_TOGGLE(i) {led_status[i] = !led_status[i];}
|
||||
|
||||
#define LED_PERIODIC() { \
|
||||
for (uint8_t cnt = 0; cnt < NB_LED; cnt++) { \
|
||||
if (led_status[cnt]) \
|
||||
GPIOC->BSRR = GPIO_Pin_15; \
|
||||
else \
|
||||
GPIOC->BRR = GPIO_Pin_15; \
|
||||
GPIOA->BSRR = GPIO_Pin_8; /* clock rising edge */ \
|
||||
GPIOA->BRR = GPIO_Pin_8; /* clock falling edge */ \
|
||||
} \
|
||||
}
|
||||
for (uint8_t cnt = 0; cnt < NB_LED; cnt++) { \
|
||||
if (led_status[cnt]) \
|
||||
GPIO_BSRR(GPIOC) = GPIO15; \
|
||||
else \
|
||||
GPIO_BRR(GPIOC) = GPIO15; \
|
||||
GPIO_BSRR(GPIOA) = GPIO8; /* clock rising edge */ \
|
||||
GPIO_BRR(GPIOA) = GPIO8; /* clock falling edge */ \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif /* LED_STP08 */
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
#include "mcu_periph/sys_time.h"
|
||||
|
||||
#include "libopencm3/stm32/systick.h"
|
||||
|
||||
#ifdef SYS_TIME_LED
|
||||
#include "led.h"
|
||||
#endif
|
||||
@@ -38,11 +40,11 @@ void sys_time_arch_init( void ) {
|
||||
* The timer interrupt is activated on the transition from 1 to 0,
|
||||
* therefore it activates every n+1 clock ticks.
|
||||
*/
|
||||
if (SysTick_Config(SYS_TIME_RESOLUTION_CPU_TICKS-1))
|
||||
while(1); /* if reload of value is impossible, go into endless loop */
|
||||
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB);
|
||||
systick_set_reload(SYS_TIME_RESOLUTION_CPU_TICKS-1);
|
||||
|
||||
/* Set SysTick handler priority */
|
||||
NVIC_SetPriority(SysTick_IRQn, 0x0);
|
||||
systick_interrupt_enable();
|
||||
systick_counter_enable();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +53,7 @@ void sys_time_arch_init( void ) {
|
||||
// 97 days at 512hz
|
||||
// 12 hours at 100khz
|
||||
//
|
||||
void sys_tick_irq_handler(void) {
|
||||
void sys_tick_handler(void) {
|
||||
|
||||
sys_time.nb_tick++;
|
||||
sys_time.nb_sec_rem += SYS_TIME_RESOLUTION_CPU_TICKS;
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
|
||||
#include "mcu_periph/sys_time.h"
|
||||
|
||||
#include <stm32/gpio.h>
|
||||
#include <stm32/rcc.h>
|
||||
#include <libopencm3/stm32/f1/gpio.h>
|
||||
#include <libopencm3/stm32/f1/rcc.h>
|
||||
#include "std.h"
|
||||
|
||||
extern void sys_tick_irq_handler(void);
|
||||
|
||||
@@ -10,20 +10,20 @@
|
||||
/* Onboard LEDs */
|
||||
#define LED_1_BANK
|
||||
#define LED_1_GPIO GPIOB
|
||||
#define LED_1_GPIO_CLK RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO
|
||||
#define LED_1_GPIO_PIN GPIO_Pin_4
|
||||
#define LED_1_AFIO_REMAP GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE)
|
||||
#define LED_1_GPIO_CLK RCC_APB2ENR_IOPBEN | RCC_APB2ENR_AFIOEN
|
||||
#define LED_1_GPIO_PIN GPIO4
|
||||
#define LED_1_AFIO_REMAP AFIO_MAPR |= AFIO_MAPR_SWJ_CFG_FULL_SWJ_NO_JNTRST
|
||||
|
||||
#define LED_2_BANK
|
||||
#define LED_2_GPIO GPIOC
|
||||
#define LED_2_GPIO_CLK RCC_APB2Periph_GPIOC
|
||||
#define LED_2_GPIO_PIN GPIO_Pin_5
|
||||
#define LED_2_GPIO_CLK RCC_APB2ENR_IOPCEN
|
||||
#define LED_2_GPIO_PIN GPIO5
|
||||
#define LED_2_AFIO_REMAP ((void)0)
|
||||
|
||||
#define LED_3_BANK
|
||||
#define LED_3_GPIO GPIOC
|
||||
#define LED_3_GPIO_CLK RCC_APB2Periph_GPIOC
|
||||
#define LED_3_GPIO_PIN GPIO_Pin_2
|
||||
#define LED_3_GPIO_CLK RCC_APB2ENR_IOPCEN
|
||||
#define LED_3_GPIO_PIN GPIO2
|
||||
#define LED_3_AFIO_REMAP ((void)0)
|
||||
|
||||
|
||||
|
||||
@@ -21,14 +21,11 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stm32/flash.h>
|
||||
#include <stm32/misc.h>
|
||||
|
||||
#include BOARD_CONFIG
|
||||
#include "mcu.h"
|
||||
#include "led.h"
|
||||
|
||||
void Delay(__IO uint32_t nCount);
|
||||
void Delay(volatile uint32_t nCount);
|
||||
void led_on(int i);
|
||||
void led_off(int i);
|
||||
|
||||
@@ -103,7 +100,13 @@ int main(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Delay(__IO uint32_t nCount) {
|
||||
/*
|
||||
* XXX: do we really need volatile here?
|
||||
*
|
||||
* Also we should probably use systime instead as it is being linked into this
|
||||
* test anyways...
|
||||
*/
|
||||
void Delay(volatile uint32_t nCount) {
|
||||
for(; nCount != 0; nCount--);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user