Fixed all warnings for examples.

This commit is contained in:
Piotr Esden-Tempski 2013-02-26 19:33:42 -08:00
parent 9c552e7585
commit 3d3ddc7014
88 changed files with 365 additions and 306 deletions

View File

@ -20,7 +20,7 @@
#include <libopencm3/lm3s/systemcontrol.h>
#include <libopencm3/lm3s/gpio.h>
void gpio_setup(void)
static void gpio_setup(void)
{
SYSTEMCONTROL_RCGC2 |= 0x20; /* Enable GPIOF in run mode. */

View File

@ -149,8 +149,6 @@ static void delay(void)
int main(void)
{
int i;
clock_setup();
gpio_setup();
irq_setup();

View File

@ -20,7 +20,7 @@
// #include <libopencm3/lpc13xx/rcc.h>
#include <libopencm3/lpc13xx/gpio.h>
void gpio_setup(void)
static void gpio_setup(void)
{
GPIO3_DIR |= (1 << 0); /* Configure P3_0 as output. */
}

View File

@ -19,7 +19,7 @@
#include <libopencm3/lpc17xx/gpio.h>
void gpio_setup(void)
static void gpio_setup(void)
{
GPIO1_DIR |= (1 << 29); /* Configure P1_29 as output. */
}

View File

@ -20,7 +20,7 @@
#include <libopencm3/lpc43xx/gpio.h>
void gpio_setup(void)
static void gpio_setup(void)
{
GPIO0_DIR |= (1 << 5); /* Configure GPIO0[5] (P6_6) as output. */
}

View File

@ -23,7 +23,7 @@
#include "../jellybean_conf.h"
void gpio_setup(void)
static void gpio_setup(void)
{
/* Configure SCU Pin Mux as GPIO */
scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_FAST);
@ -55,7 +55,8 @@ void gpio_setup(void)
#define SI5351C_I2C_ADDR (0x60 << 1)
/* write to single register */
void si5351c_write_reg(uint8_t reg, uint8_t val)
/* Not used!
static void si5351c_write_reg(uint8_t reg, uint8_t val)
{
i2c0_tx_start();
i2c0_tx_byte(SI5351C_I2C_ADDR | I2C_WRITE);
@ -63,9 +64,10 @@ void si5351c_write_reg(uint8_t reg, uint8_t val)
i2c0_tx_byte(val);
i2c0_stop();
}
*/
/* read single register */
uint8_t si5351c_read_reg(uint8_t reg)
static uint8_t si5351c_read_reg(uint8_t reg)
{
uint8_t val;

View File

@ -23,7 +23,7 @@
#include "../jellybean_conf.h"
void gpio_setup(void)
static void gpio_setup(void)
{
/* Configure SCU Pin Mux as GPIO */
scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_FAST);

View File

@ -23,7 +23,7 @@
#include "../jellybean_conf.h"
void gpio_setup(void)
static void gpio_setup(void)
{
/* Configure SCU Pin Mux as GPIO */
scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_FAST);

View File

@ -24,7 +24,7 @@
#include "../jellybean_conf.h"
void gpio_setup(void)
static void gpio_setup(void)
{
/* Configure all GPIO as Input (safe state) */
GPIO0_DIR = 0;

View File

@ -30,7 +30,7 @@
volatile u32 g_ulSysTickCount;
u32 g_NbCyclePerSecond;
void gpio_setup(void)
static void gpio_setup(void)
{
/* Configure all GPIO as Input (safe state) */
GPIO0_DIR = 0;
@ -65,7 +65,7 @@ void gpio_setup(void)
GPIO3_DIR |= PIN_EN1V8; /* GPIO3[6] on P6_10 as output. */
}
void systick_setup(void)
static void systick_setup(void)
{
u32 systick_reload_val;
g_ulSysTickCount = 0;
@ -100,18 +100,18 @@ void systick_setup(void)
asm volatile ("cpsie i");
}
void scs_dwt_cycle_counter_enabled(void)
static void scs_dwt_cycle_counter_enabled(void)
{
SCS_DEMCR |= SCS_DEMCR_TRCENA;
SCS_DWT_CTRL |= SCS_DWT_CTRL_CYCCNTENA;
}
u32 sys_tick_get_time_ms(void)
static u32 sys_tick_get_time_ms(void)
{
return g_ulSysTickCount;
}
u32 sys_tick_delta_time_ms(u32 start, u32 end)
static u32 sys_tick_delta_time_ms(u32 start, u32 end)
{
#define MAX_T_U32 ((2^32)-1)
u32 diff;
@ -127,7 +127,7 @@ u32 sys_tick_delta_time_ms(u32 start, u32 end)
return diff;
}
void sys_tick_wait_time_ms(u32 wait_ms)
static void sys_tick_wait_time_ms(u32 wait_ms)
{
u32 start, end;
u32 tickms;

View File

@ -47,7 +47,7 @@ struct can_rx_msg {
struct can_tx_msg can_tx_msg;
struct can_rx_msg can_rx_msg;
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable Alternate Function clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
@ -85,7 +85,7 @@ void gpio_setup(void)
}
void systick_setup(void)
static void systick_setup(void)
{
/* 72MHz / 8 => 9000000 counts per second */
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
@ -100,7 +100,7 @@ void systick_setup(void)
systick_counter_enable();
}
void can_setup(void)
static void can_setup(void)
{
/* Enable peripheral clocks. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);

View File

@ -22,7 +22,7 @@
#include <libopencm3/stm32/f1/gpio.h>
/* Set STM32 to 72 MHz. */
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_12mhz_out_72mhz();
@ -32,7 +32,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO13 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ,

View File

@ -177,8 +177,8 @@ static int cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *
* even though it's optional in the CDC spec, and we don't
* advertise it in the ACM functional descriptor.
*/
char buf[10];
struct usb_cdc_notification *notif = (void*)buf;
char local_buf[10];
struct usb_cdc_notification *notif = (void*)local_buf;
/* We echo signals back to host as notification. */
notif->bmRequestType = 0xA1;
@ -186,8 +186,8 @@ static int cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *
notif->wValue = 0;
notif->wIndex = 0;
notif->wLength = 2;
buf[8] = req->wValue & 3;
buf[9] = 0;
local_buf[8] = req->wValue & 3;
local_buf[9] = 0;
// usbd_ep_write_packet(0x83, buf, 10);
return 1;
}

View File

@ -141,16 +141,24 @@ static void usbdfu_getstatus_complete(usbd_device *usbd_dev, struct usb_setup_da
if (prog.blocknum == 0) {
switch (prog.buf[0]) {
case CMD_ERASE:
flash_erase_page(*(u32 *)(prog.buf + 1));
{
u32 *dat = (u32 *)(prog.buf + 1);
flash_erase_page(*dat);
}
case CMD_SETADDR:
prog.addr = *(u32 *)(prog.buf + 1);
{
u32 *dat = (u32 *)(prog.buf + 1);
prog.addr = *dat;
}
}
} else {
u32 baseaddr = prog.addr + ((prog.blocknum - 2) *
dfu_function.wTransferSize);
for (i = 0; i < prog.len; i += 2)
for (i = 0; i < prog.len; i += 2) {
u16 *dat = (u16 *)(prog.buf + i);
flash_program_half_word(baseaddr + i,
*(u16 *)(prog.buf + i));
*dat);
}
}
flash_lock();

View File

@ -24,6 +24,7 @@
#include <libopencm3/cm3/systick.h>
#include <libopencm3/stm32/spi.h>
#include <libopencm3/stm32/otg_fs.h>
#include <libopencm3/stm32/f1/nvic.h>
#include <libopencm3/usb/usbd.h>
#include <libopencm3/usb/hid.h>
#include "adxl345.h"
@ -38,7 +39,7 @@
static usbd_device *usbd_dev;
const struct usb_device_descriptor dev = {
const struct usb_device_descriptor dev_descr = {
.bLength = USB_DT_DEVICE_SIZE,
.bDescriptorType = USB_DT_DEVICE,
.bcdUSB = 0x0200,
@ -174,11 +175,11 @@ static const char *usb_strings[] = {
"DEMO",
};
static int hid_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, u8 **buf, u16 *len,
void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req))
static int hid_control_request(usbd_device *dev, struct usb_setup_data *req, u8 **buf, u16 *len,
void (**complete)(usbd_device *dev, struct usb_setup_data *req))
{
(void)complete;
(void)usbd_dev;
(void)dev;
if((req->bmRequestType != 0x81) ||
(req->bRequest != USB_REQ_GET_DESCRIPTOR) ||
@ -193,10 +194,10 @@ static int hid_control_request(usbd_device *usbd_dev, struct usb_setup_data *req
}
#ifdef INCLUDE_DFU_INTERFACE
static void dfu_detach_complete(usbd_device *usbd_dev, struct usb_setup_data *req)
static void dfu_detach_complete(usbd_device *dev, struct usb_setup_data *req)
{
(void)req;
(void)usbd_dev;
(void)dev;
gpio_set_mode(GPIOA, GPIO_MODE_INPUT, 0, GPIO15);
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
@ -205,12 +206,12 @@ static void dfu_detach_complete(usbd_device *usbd_dev, struct usb_setup_data *re
scb_reset_core();
}
static int dfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, u8 **buf, u16 *len,
void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req))
static int dfu_control_request(usbd_device *dev, struct usb_setup_data *req, u8 **buf, u16 *len,
void (**complete)(usbd_device *dev, struct usb_setup_data *req))
{
(void)buf;
(void)len;
(void)usbd_dev;
(void)dev;
if ((req->bmRequestType != 0x21) || (req->bRequest != DFU_DETACH))
return 0; /* Only accept class request. */
@ -221,20 +222,20 @@ static int dfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *req
}
#endif
static void hid_set_config(usbd_device *usbd_dev, u16 wValue)
static void hid_set_config(usbd_device *dev, u16 wValue)
{
(void)wValue;
usbd_ep_setup(usbd_dev, 0x81, USB_ENDPOINT_ATTR_INTERRUPT, 4, NULL);
usbd_ep_setup(dev, 0x81, USB_ENDPOINT_ATTR_INTERRUPT, 4, NULL);
usbd_register_control_callback(
usbd_dev,
dev,
USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_INTERFACE,
USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT,
hid_control_request);
#ifdef INCLUDE_DFU_INTERFACE
usbd_register_control_callback(
usbd_dev,
dev,
USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE,
USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT,
dfu_control_request);
@ -336,7 +337,7 @@ int main(void)
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, GPIO2);
usbd_dev = usbd_init(&stm32f107_usb_driver, &dev, &config, usb_strings, 3);
usbd_dev = usbd_init(&stm32f107_usb_driver, &dev_descr, &config, usb_strings, 3);
usbd_register_set_config_callback(usbd_dev, hid_set_config);
/* Delay some seconds to show that pull-up switch works. */

View File

@ -25,7 +25,7 @@
#include <libopencm3/stm32/f1/adc.h>
#include <libopencm3/stm32/usart.h>
void usart_setup(void)
static void usart_setup(void)
{
/* Enable clocks for GPIO port A (for GPIO_USART1_TX) and USART1. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -47,7 +47,7 @@ void usart_setup(void)
usart_enable(USART2);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIO clocks. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -60,7 +60,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO15);
}
void adc_setup(void)
static void adc_setup(void)
{
int i;
@ -94,7 +94,7 @@ void adc_setup(void)
while ((ADC_CR2(ADC1) & ADC_CR2_CAL) != 0); //added this check
}
void my_usart_print_int(u32 usart, int value)
static void my_usart_print_int(u32 usart, int value)
{
s8 i;
u8 nr_digits = 0;

View File

@ -26,7 +26,7 @@
#include <libopencm3/stm32/usart.h>
#include <libopencm3/stm32/timer.h>
void usart_setup(void)
static void usart_setup(void)
{
/* Enable clocks for GPIO port A (for GPIO_USART1_TX) and USART1. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -48,7 +48,7 @@ void usart_setup(void)
usart_enable(USART2);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIO clocks. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -61,7 +61,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO15);
}
void timer_setup(void)
static void timer_setup(void)
{
/* Set up the timer TIM2 for injected sampling */
uint32_t timer;
@ -86,7 +86,7 @@ void timer_setup(void)
timer_enable_counter(timer);
}
void adc_setup(void)
static void adc_setup(void)
{
int i;
@ -120,7 +120,7 @@ void adc_setup(void)
while ((ADC_CR2(ADC1) & ADC_CR2_CAL) != 0);
}
void my_usart_print_int(u32 usart, int value)
static void my_usart_print_int(u32 usart, int value)
{
s8 i;
u8 nr_digits = 0;

View File

@ -29,7 +29,7 @@
volatile u16 temperature = 0;
void usart_setup(void)
static void usart_setup(void)
{
/* Enable clocks for GPIO port A (for GPIO_USART1_TX) and USART1. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -51,7 +51,7 @@ void usart_setup(void)
usart_enable(USART2);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIO clocks. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -64,7 +64,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO15);
}
void timer_setup(void)
static void timer_setup(void)
{
/* Set up the timer TIM2 for injected sampling */
uint32_t timer;
@ -89,14 +89,14 @@ void timer_setup(void)
timer_enable_counter(timer);
}
void irq_setup(void)
static void irq_setup(void)
{
/* Enable the adc1_2_isr() routine */
nvic_set_priority(NVIC_ADC1_2_IRQ, 0);
nvic_enable_irq(NVIC_ADC1_2_IRQ);
}
void adc_setup(void)
static void adc_setup(void)
{
int i;
@ -132,7 +132,7 @@ void adc_setup(void)
while ((ADC_CR2(ADC1) & ADC_CR2_CAL) != 0);
}
void my_usart_print_int(u32 usart, int value)
static void my_usart_print_int(u32 usart, int value)
{
s8 i;
u8 nr_digits = 0;

View File

@ -33,7 +33,7 @@ volatile u16 lisam_adc1 = 0;
volatile u16 lisam_adc2 = 0;
u8 channel_array[4]; /* for injected sampling, 4 channels max, for regular, 16 max */
void usart_setup(void)
static void usart_setup(void)
{
/* Enable clocks for GPIO port A (for GPIO_USART1_TX) and USART1. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -55,7 +55,7 @@ void usart_setup(void)
usart_enable(USART2);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIO clocks. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -72,7 +72,7 @@ void gpio_setup(void)
GPIO3 | GPIO0 );
}
void timer_setup(void)
static void timer_setup(void)
{
/* Set up the timer TIM2 for injected sampling */
uint32_t timer;
@ -97,14 +97,14 @@ void timer_setup(void)
timer_enable_counter(timer);
}
void irq_setup(void)
static void irq_setup(void)
{
/* Enable the adc1_2_isr() routine */
nvic_set_priority(NVIC_ADC1_2_IRQ, 0);
nvic_enable_irq(NVIC_ADC1_2_IRQ);
}
void adc_setup(void)
static void adc_setup(void)
{
int i;
@ -149,7 +149,7 @@ void adc_setup(void)
while ((ADC_CR2(ADC1) & ADC_CR2_CAL) != 0); //added this check
}
void my_usart_print_int(u32 usart, int value)
static void my_usart_print_int(u32 usart, int value)
{
s8 i;
u8 nr_digits = 0;

View File

@ -25,7 +25,7 @@
#include <libopencm3/stm32/f1/adc.h>
#include <libopencm3/stm32/usart.h>
void usart_setup(void)
static void usart_setup(void)
{
/* Enable clocks for GPIO port A (for GPIO_USART1_TX) and USART1. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -47,7 +47,7 @@ void usart_setup(void)
usart_enable(USART2);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIO clocks. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -60,7 +60,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO15);
}
void adc_setup(void)
static void adc_setup(void)
{
int i;
@ -88,7 +88,7 @@ void adc_setup(void)
adc_calibration(ADC1);
}
void my_usart_print_int(u32 usart, int value)
static void my_usart_print_int(u32 usart, int value)
{
s8 i;
u8 nr_digits = 0;

View File

@ -47,7 +47,7 @@ struct can_rx_msg {
struct can_tx_msg can_tx_msg;
struct can_rx_msg can_rx_msg;
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable Alternate Function clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
@ -85,7 +85,7 @@ void gpio_setup(void)
}
void systick_setup(void)
static void systick_setup(void)
{
/* 72MHz / 8 => 9000000 counts per second */
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
@ -100,7 +100,7 @@ void systick_setup(void)
systick_counter_enable();
}
void can_setup(void)
static void can_setup(void)
{
/* Enable peripheral clocks. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);

View File

@ -22,7 +22,7 @@
#include <libopencm3/stm32/f1/gpio.h>
/* Set STM32 to 72 MHz. */
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_12mhz_out_72mhz();
@ -33,7 +33,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* LED1 */
/* Set GPIO8 (in GPIO port A) to 'output push-pull'. */
@ -70,7 +70,7 @@ void gpio_setup(void)
gpio_set(GPIOC, GPIO2);
}
void led_set(int id, int on)
static void led_set(int id, int on)
{
if (on) {
switch (id) {
@ -111,7 +111,7 @@ void led_set(int id, int on)
}
}
void led_advance(void)
static void led_advance(void)
{
static int state = 0;

View File

@ -21,7 +21,7 @@
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/usart.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_12mhz_out_72mhz();
@ -35,7 +35,7 @@ void clock_setup(void)
RCC_APB1ENR_USART2EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Setup GPIO pin GPIO_USART2_TX. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
@ -54,7 +54,7 @@ void usart_setup(void)
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO8 (in GPIO port A) to 'output push-pull'. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,

View File

@ -23,7 +23,7 @@
#include <libopencm3/stm32/f1/dma.h>
#include <libopencm3/cm3/nvic.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_12mhz_out_72mhz();
@ -40,7 +40,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_DMA1EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Setup GPIO pin GPIO_USART2_TX and GPIO_USART2_RX. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
@ -67,7 +67,7 @@ void usart_setup(void)
}
void dma_write(char *data, int size)
static void dma_write(char *data, int size)
{
/*
* Using channel 7 for USART2_TX
@ -109,7 +109,7 @@ void dma1_channel7_isr(void)
dma_disable_channel(DMA1, DMA_CHANNEL7);
}
void dma_read(char *data, int size)
static void dma_read(char *data, int size)
{
/*
* Using channel 6 for USART2_RX
@ -151,7 +151,7 @@ void dma1_channel6_isr(void)
dma_disable_channel(DMA1, DMA_CHANNEL6);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO8 (in GPIO port A) to 'output push-pull'. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,

View File

@ -22,7 +22,7 @@
#include <libopencm3/stm32/usart.h>
#include <libopencm3/cm3/nvic.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_12mhz_out_72mhz();
@ -36,7 +36,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Enable the USART2 interrupt. */
nvic_enable_irq(NVIC_USART2_IRQ);
@ -64,7 +64,7 @@ void usart_setup(void)
usart_enable(USART2);
}
void gpio_setup(void)
static void gpio_setup(void)
{
gpio_set(GPIOA, GPIO8);

View File

@ -45,7 +45,9 @@ struct ring {
#define RING_DATA(RING) (RING)->data
#define RING_EMPTY(RING) ((RING)->begin == (RING)->end)
void ring_init(struct ring *ring, u8 *buf, ring_size_t size)
int _write(int file, char *ptr, int len);
static void ring_init(struct ring *ring, u8 *buf, ring_size_t size)
{
ring->data = buf;
ring->size = size;
@ -53,7 +55,7 @@ void ring_init(struct ring *ring, u8 *buf, ring_size_t size)
ring->end = 0;
}
s32 ring_write_ch(struct ring *ring, u8 ch)
static s32 ring_write_ch(struct ring *ring, u8 ch)
{
if (((ring->end + 1) % ring->size) != ring->begin) {
ring->data[ring->end++] = ch;
@ -64,7 +66,7 @@ s32 ring_write_ch(struct ring *ring, u8 ch)
return -1;
}
s32 ring_write(struct ring *ring, u8 *data, ring_size_t size)
static s32 ring_write(struct ring *ring, u8 *data, ring_size_t size)
{
s32 i;
@ -76,7 +78,7 @@ s32 ring_write(struct ring *ring, u8 *data, ring_size_t size)
return i;
}
s32 ring_read_ch(struct ring *ring, u8 *ch)
static s32 ring_read_ch(struct ring *ring, u8 *ch)
{
s32 ret = -1;
@ -90,7 +92,8 @@ s32 ring_read_ch(struct ring *ring, u8 *ch)
return ret;
}
s32 ring_read(struct ring *ring, u8 *data, ring_size_t size)
/* Not used!
static s32 ring_read(struct ring *ring, u8 *data, ring_size_t size)
{
s32 i;
@ -101,6 +104,7 @@ s32 ring_read(struct ring *ring, u8 *data, ring_size_t size)
return -i;
}
*/
/******************************************************************************
* The example implementation
@ -111,7 +115,7 @@ s32 ring_read(struct ring *ring, u8 *data, ring_size_t size)
struct ring output_ring;
u8 output_ring_buffer[BUFFER_SIZE];
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_12mhz_out_72mhz();
@ -124,7 +128,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Initialize output ring buffer. */
ring_init(&output_ring, output_ring_buffer, BUFFER_SIZE);
@ -155,7 +159,7 @@ void usart_setup(void)
usart_enable(USART2);
}
void gpio_setup(void)
static void gpio_setup(void)
{
gpio_set(GPIOA, GPIO8);
@ -217,7 +221,7 @@ int _write(int file, char *ptr, int len)
return -1;
}
void systick_setup(void)
static void systick_setup(void)
{
/* 72MHz / 8 => 9000000 counts per second. */
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);

View File

@ -25,7 +25,9 @@
#include <stdio.h>
#include <errno.h>
void clock_setup(void)
int _write(int file, char *ptr, int len);
static void clock_setup(void)
{
rcc_clock_setup_in_hse_12mhz_out_72mhz();
@ -38,7 +40,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Setup GPIO pin GPIO_USART2_RE_TX on GPIO port B for transmit. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
@ -56,7 +58,7 @@ void usart_setup(void)
usart_enable(USART2);
}
void gpio_setup(void)
static void gpio_setup(void)
{
gpio_set(GPIOA, GPIO8);

View File

@ -21,7 +21,7 @@
#include <libopencm3/stm32/f1/rcc.h>
#include <libopencm3/stm32/f1/gpio.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -29,7 +29,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO6/7/8/9 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ,

View File

@ -236,7 +236,7 @@ static const u16 gamma_table_3_0[] = {
};
#endif
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -248,7 +248,7 @@ void clock_setup(void)
RCC_APB2ENR_IOPAEN | RCC_APB2ENR_AFIOEN);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/*
* Set GPIO_TIM1_CH1/2/3/4 (in GPIO port A) to
@ -269,7 +269,7 @@ void gpio_setup(void)
// AFIO_MAPR |= AFIO_MAPR_TIM3_REMAP_FULL_REMAP;
}
void tim_setup(void)
static void tim_setup(void)
{
#if 0
TIM1_CR1 = TIM_CR1_CMS_CENTER_1 | TIM_CR1_ARPE;

View File

@ -46,7 +46,7 @@ struct can_rx_msg {
struct can_tx_msg can_tx_msg;
struct can_rx_msg can_rx_msg;
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable Alternate Function clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
@ -69,7 +69,7 @@ void gpio_setup(void)
}
void systick_setup(void)
static void systick_setup(void)
{
/* 64MHz / 8 => 8000000 counts per second */
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
@ -84,7 +84,7 @@ void systick_setup(void)
systick_counter_enable();
}
void can_setup(void)
static void can_setup(void)
{
/* Enable peripheral clocks. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);

View File

@ -20,7 +20,7 @@
#include <libopencm3/stm32/f1/rcc.h>
#include <libopencm3/stm32/f1/gpio.h>
void clock_setup(void)
static void clock_setup(void)
{
/* Set STM32 to 64 MHz. */
rcc_clock_setup_in_hsi_out_64mhz();
@ -32,7 +32,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Configure PB4 as GPIO. */

View File

@ -25,7 +25,7 @@
u32 temp32;
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable alternate function peripheral clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);

View File

@ -21,7 +21,7 @@
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/usart.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hsi_out_64mhz();
@ -31,7 +31,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART1EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Setup GPIO6 (in GPIO port A) to 'output push-pull' for LED use. */
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
@ -55,7 +55,7 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO5 (in GPIO port B) to 'output push-pull'. */
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,

View File

@ -47,7 +47,7 @@ struct can_rx_msg {
struct can_tx_msg can_tx_msg;
struct can_rx_msg can_rx_msg;
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOA clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -73,7 +73,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO1);
}
void systick_setup(void)
static void systick_setup(void)
{
/* 72MHz / 8 => 9000000 counts per second */
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
@ -88,7 +88,7 @@ void systick_setup(void)
systick_counter_enable();
}
void can_setup(void)
static void can_setup(void)
{
/* Enable peripheral clocks. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);

View File

@ -21,7 +21,7 @@
#include <libopencm3/stm32/f1/rcc.h>
#include <libopencm3/stm32/f1/gpio.h>
void clock_setup(void)
static void clock_setup(void)
{
/* Set STM32 to 72 MHz. */
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -33,7 +33,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO6 and 7 (in GPIO port A) to 'output push-pull'. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,

View File

@ -236,7 +236,7 @@ static const u16 gamma_table_3_0[] = {
};
#endif
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -250,7 +250,7 @@ void clock_setup(void)
RCC_APB2ENR_AFIOEN);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/*
* Set GPIO6 and 7 (in GPIO port A) to
@ -269,7 +269,8 @@ void gpio_setup(void)
GPIO_TIM3_CH3 | GPIO_TIM3_CH4);
}
void tim_setup(void)
static void tim_setup(void)
{
/* Clock division and mode */
TIM3_CR1 = TIM_CR1_CKD_CK_INT | TIM_CR1_CMS_EDGE;

View File

@ -26,7 +26,7 @@
u32 temp32;
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOA clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);

View File

@ -21,7 +21,7 @@
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/usart.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -34,7 +34,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART1EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Setup GPIO6 (in GPIO port A) to 'output push-pull' for LED use. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
@ -58,7 +58,7 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO6 (in GPIO port A) to 'output push-pull'. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,

View File

@ -22,7 +22,7 @@
#include <libopencm3/stm32/usart.h>
#include <libopencm3/cm3/nvic.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -35,7 +35,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART1EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Enable the USART1 interrupt. */
nvic_enable_irq(NVIC_USART1_IRQ);
@ -66,7 +66,7 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
gpio_set(GPIOA, GPIO6 | GPIO7);

View File

@ -23,7 +23,7 @@
#include <libopencm3/stm32/f1/adc.h>
#include <libopencm3/stm32/usart.h>
void usart_setup(void)
static void usart_setup(void)
{
/* Enable clocks for GPIO port A (for GPIO_USART1_TX) and USART1. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -45,7 +45,7 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOB clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
@ -57,7 +57,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO7);
}
void adc_setup(void)
static void adc_setup(void)
{
int i;
@ -85,7 +85,7 @@ void adc_setup(void)
adc_calibration(ADC1);
}
void my_usart_print_int(u32 usart, int value)
static void my_usart_print_int(u32 usart, int value)
{
s8 i;
u8 nr_digits = 0;

View File

@ -23,7 +23,7 @@
#include <libopencm3/stm32/f1/dma.h>
#include <libopencm3/stm32/usart.h>
void usart_setup(void)
static void usart_setup(void)
{
/* Enable clocks for GPIO port A (for GPIO_USART1_TX) and USART1. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -45,7 +45,7 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOB clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
@ -57,7 +57,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO7);
}
void my_usart_print_string(u32 usart, char *s)
static void my_usart_print_string(u32 usart, char *s)
{
while (*s != 0) {
usart_send(usart, *s);

View File

@ -26,7 +26,7 @@
#include <libopencm3/stm32/spi.h>
#include "./dogm128.h"
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOB clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
@ -53,7 +53,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO15);
}
void spi_setup(void)
static void spi_setup(void)
{
/* The DOGM128 display is connected to SPI2, so initialise it. */

View File

@ -24,7 +24,7 @@
#include <libopencm3/stm32/i2c.h>
#include "stts75.h"
void usart_setup(void)
static void usart_setup(void)
{
/* Enable clocks for GPIO port A (for GPIO_USART1_TX) and USART1. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -46,7 +46,7 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOB clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
@ -58,7 +58,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO7);
}
void i2c_setup(void)
static void i2c_setup(void)
{
/* Enable clocks for I2C2 and AFIO. */
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_I2C2EN);

View File

@ -24,7 +24,7 @@
#include <libopencm3/stm32/pwr.h>
#include <libopencm3/cm3/nvic.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -36,7 +36,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART1EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Setup GPIO pin GPIO_USART1_TX/GPIO9 on GPIO port A for transmit. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
@ -54,14 +54,14 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO12 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
}
void nvic_setup(void)
static void nvic_setup(void)
{
/* Without this the RTC interrupt routine will never be called. */
nvic_enable_irq(NVIC_RTC_IRQ);

View File

@ -25,7 +25,7 @@
u32 temp32;
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOB clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);

View File

@ -23,7 +23,7 @@
#include <libopencm3/stm32/timer.h>
#include <libopencm3/cm3/nvic.h>
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOB clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
@ -35,7 +35,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO7);
}
void nvic_setup(void)
static void nvic_setup(void)
{
/* Without this the timer interrupt routine will never be called. */
nvic_enable_irq(NVIC_TIM2_IRQ);

View File

@ -177,8 +177,8 @@ static int cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *
* even though it's optional in the CDC spec, and we don't
* advertise it in the ACM functional descriptor.
*/
char buf[10];
struct usb_cdc_notification *notif = (void *)buf;
char local_buf[10];
struct usb_cdc_notification *notif = (void *)local_buf;
/* We echo signals back to host as notification. */
notif->bmRequestType = 0xA1;
@ -186,8 +186,8 @@ static int cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *
notif->wValue = 0;
notif->wIndex = 0;
notif->wLength = 2;
buf[8] = req->wValue & 3;
buf[9] = 0;
local_buf[8] = req->wValue & 3;
local_buf[9] = 0;
// usbd_ep_write_packet(0x83, buf, 10);
return 1;
}

View File

@ -141,16 +141,24 @@ static void usbdfu_getstatus_complete(usbd_device *usbd_dev, struct usb_setup_da
if (prog.blocknum == 0) {
switch (prog.buf[0]) {
case CMD_ERASE:
flash_erase_page(*(u32 *)(prog.buf + 1));
{
u32 *dat = (u32 *)(prog.buf + 1);
flash_erase_page(*dat);
}
case CMD_SETADDR:
prog.addr = *(u32 *)(prog.buf + 1);
{
u32 *dat = (u32 *)(prog.buf + 1);
prog.addr = *dat;
}
}
} else {
u32 baseaddr = prog.addr + ((prog.blocknum - 2) *
dfu_function.wTransferSize);
for (i = 0; i < prog.len; i += 2)
for (i = 0; i < prog.len; i += 2) {
u16 *dat = (u16 *)(prog.buf + i);
flash_program_half_word(baseaddr + i,
*(u16 *)(prog.buf + i));
*dat);
}
}
flash_lock();

View File

@ -20,6 +20,7 @@
#include <stdlib.h>
#include <libopencm3/stm32/f1/rcc.h>
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/f1/nvic.h>
#include <libopencm3/cm3/systick.h>
#include <libopencm3/usb/usbd.h>
#include <libopencm3/usb/hid.h>
@ -34,7 +35,7 @@
static usbd_device *usbd_dev;
const struct usb_device_descriptor dev = {
const struct usb_device_descriptor dev_descr = {
.bLength = USB_DT_DEVICE_SIZE,
.bDescriptorType = USB_DT_DEVICE,
.bcdUSB = 0x0200,
@ -170,11 +171,11 @@ static const char *usb_strings[] = {
"DEMO",
};
static int hid_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, u8 **buf, u16 *len,
void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req))
static int hid_control_request(usbd_device *dev, struct usb_setup_data *req, u8 **buf, u16 *len,
void (**complete)(usbd_device *, struct usb_setup_data *))
{
(void)complete;
(void)usbd_dev;
(void)dev;
if((req->bmRequestType != 0x81) ||
(req->bRequest != USB_REQ_GET_DESCRIPTOR) ||
@ -189,10 +190,10 @@ static int hid_control_request(usbd_device *usbd_dev, struct usb_setup_data *req
}
#ifdef INCLUDE_DFU_INTERFACE
static void dfu_detach_complete(usbd_device *usbd_dev, struct usb_setup_data *req)
static void dfu_detach_complete(usbd_device *dev, struct usb_setup_data *req)
{
(void)req;
(void)usbd_dev;
(void)dev;
gpio_set_mode(GPIOA, GPIO_MODE_INPUT, 0, GPIO15);
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
@ -201,12 +202,12 @@ static void dfu_detach_complete(usbd_device *usbd_dev, struct usb_setup_data *re
scb_reset_core();
}
static int dfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, u8 **buf, u16 *len,
void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req))
static int dfu_control_request(usbd_device *dev, struct usb_setup_data *req, u8 **buf, u16 *len,
void (**complete)(usbd_device *, struct usb_setup_data *))
{
(void)buf;
(void)len;
(void)usbd_dev;
(void)dev;
if ((req->bmRequestType != 0x21) || (req->bRequest != DFU_DETACH))
return 0; /* Only accept class request. */
@ -217,21 +218,21 @@ static int dfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *req
}
#endif
static void hid_set_config(usbd_device *usbd_dev, u16 wValue)
static void hid_set_config(usbd_device *dev, u16 wValue)
{
(void)wValue;
(void)usbd_dev;
(void)dev;
usbd_ep_setup(usbd_dev, 0x81, USB_ENDPOINT_ATTR_INTERRUPT, 4, NULL);
usbd_ep_setup(dev, 0x81, USB_ENDPOINT_ATTR_INTERRUPT, 4, NULL);
usbd_register_control_callback(
usbd_dev,
dev,
USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_INTERFACE,
USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT,
hid_control_request);
#ifdef INCLUDE_DFU_INTERFACE
usbd_register_control_callback(
usbd_dev,
dev,
USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE,
USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT,
dfu_control_request);
@ -254,7 +255,7 @@ int main(void)
AFIO_MAPR |= AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON;
gpio_set_mode(GPIOA, GPIO_MODE_INPUT, 0, GPIO15);
usbd_dev = usbd_init(&stm32f103_usb_driver, &dev, &config, usb_strings, 3);
usbd_dev = usbd_init(&stm32f103_usb_driver, &dev_descr, &config, usb_strings, 3);
usbd_register_set_config_callback(usbd_dev, hid_set_config);
gpio_set(GPIOA, GPIO15);

View File

@ -26,12 +26,12 @@
u16 exti_line_state;
/* Set STM32 to 72 MHz. */
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOC clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
@ -41,7 +41,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
}
void button_setup(void)
static void button_setup(void)
{
/* Enable GPIOA clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);

View File

@ -26,12 +26,12 @@
u16 exti_line_state;
/* Set STM32 to 72 MHz. */
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOC clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
@ -41,7 +41,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
}
void exti_setup(void)
static void exti_setup(void)
{
/* Enable GPIOA clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);

View File

@ -29,12 +29,12 @@
u16 exti_direction = FALLING;
/* Set STM32 to 72 MHz. */
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOC clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
@ -44,7 +44,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
}
void exti_setup(void)
static void exti_setup(void)
{
/* Enable GPIOA clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);

View File

@ -21,7 +21,7 @@
#include <libopencm3/stm32/f1/gpio.h>
/* Set STM32 to 72 MHz. */
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -29,7 +29,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO12 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ,

View File

@ -63,7 +63,7 @@ struct color {
};
/* Set STM32 to 72 MHz. */
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -72,7 +72,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO12 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ,
@ -87,7 +87,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO15);
}
void send_colors(struct color *colors, int count)
static void send_colors(struct color *colors, int count)
{
int i, k;
@ -148,7 +148,7 @@ void send_colors(struct color *colors, int count)
}
}
void reset_colors(struct color *colors, int count)
static void reset_colors(struct color *colors, int count)
{
int i;
@ -159,7 +159,7 @@ void reset_colors(struct color *colors, int count)
}
}
void init_colors(struct color *colors, int count)
static void init_colors(struct color *colors, int count)
{
colors[0].r = 0x1F;
colors[0].g = 0;
@ -174,7 +174,7 @@ void init_colors(struct color *colors, int count)
count = count;
}
void step_colors(struct color *colors, int count)
static void step_colors(struct color *colors, int count)
{
int i;
struct color tmp_color1;

View File

@ -20,7 +20,7 @@
#include <libopencm3/stm32/f1/rcc.h>
#include <libopencm3/stm32/f1/gpio.h>
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOC clock. */
/* Manually: */

View File

@ -28,12 +28,12 @@
u16 exti_direction = FALLING;
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOC clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
@ -43,7 +43,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
}
void exti_setup(void)
static void exti_setup(void)
{
/* Enable GPIOA clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@ -80,7 +80,7 @@ void exti0_isr(void)
}
}
void tim_setup(void)
static void tim_setup(void)
{
/* Enable TIM1 clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_TIM1EN);

View File

@ -20,17 +20,17 @@
#include <libopencm3/stm32/f1/rcc.h>
#include <libopencm3/stm32/spi.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
}
void spi_setup(void)
static void spi_setup(void)
{
/* TODO */
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* TODO */
}

View File

@ -51,12 +51,12 @@ u16 new_time;
u16 frequency;
int debug = 0;
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOC clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
@ -68,7 +68,7 @@ void gpio_setup(void)
gpio_set(GPIOC, GPIO12);
}
void tim_setup(void)
static void tim_setup(void)
{
/* Enable TIM2 clock. */
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_TIM2EN);

View File

@ -25,7 +25,7 @@
#include <libopencm3/cm3/tpiu.h>
#include <libopencm3/cm3/itm.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -33,7 +33,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
}
void trace_setup(void)
static void trace_setup(void)
{
/* Enable trace subsystem (we'll use ITM and TPIU). */
SCS_DEMCR |= SCS_DEMCR_TRCENA;
@ -61,14 +61,14 @@ void trace_setup(void)
ITM_TER[0] = 1;
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO12 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
}
void trace_send_blocking(char c)
static void trace_send_blocking(char c)
{
while (!(ITM_STIM[0] & ITM_STIM_FIFOREADY))
;

View File

@ -21,7 +21,7 @@
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/usart.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -37,7 +37,7 @@ void clock_setup(void)
RCC_APB1ENR_USART3EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Setup GPIO pin GPIO_USART1_TX. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
@ -85,7 +85,7 @@ void usart_setup(void)
usart_enable(USART3);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO12 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ,

View File

@ -22,7 +22,7 @@
#include <libopencm3/stm32/usart.h>
#include <libopencm3/cm3/nvic.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -34,7 +34,7 @@ void clock_setup(void)
RCC_APB2ENR_AFIOEN | RCC_APB2ENR_USART1EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Enable the USART1 interrupt. */
nvic_enable_irq(NVIC_USART1_IRQ);
@ -62,7 +62,7 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
gpio_set(GPIOC, GPIO12);

View File

@ -45,7 +45,7 @@ struct ring {
#define RING_DATA(RING) (RING)->data
#define RING_EMPTY(RING) ((RING)->begin == (RING)->end)
void ring_init(struct ring *ring, u8 *buf, ring_size_t size)
static void ring_init(struct ring *ring, u8 *buf, ring_size_t size)
{
ring->data = buf;
ring->size = size;
@ -53,7 +53,7 @@ void ring_init(struct ring *ring, u8 *buf, ring_size_t size)
ring->end = 0;
}
s32 ring_write_ch(struct ring *ring, u8 ch)
static s32 ring_write_ch(struct ring *ring, u8 ch)
{
if (((ring->end + 1) % ring->size) != ring->begin) {
ring->data[ring->end++] = ch;
@ -64,7 +64,7 @@ s32 ring_write_ch(struct ring *ring, u8 ch)
return -1;
}
s32 ring_write(struct ring *ring, u8 *data, ring_size_t size)
static s32 ring_write(struct ring *ring, u8 *data, ring_size_t size)
{
s32 i;
@ -76,7 +76,7 @@ s32 ring_write(struct ring *ring, u8 *data, ring_size_t size)
return i;
}
s32 ring_read_ch(struct ring *ring, u8 *ch)
static s32 ring_read_ch(struct ring *ring, u8 *ch)
{
s32 ret = -1;
@ -90,7 +90,8 @@ s32 ring_read_ch(struct ring *ring, u8 *ch)
return ret;
}
s32 ring_read(struct ring *ring, u8 *data, ring_size_t size)
/* Not used!
static s32 ring_read(struct ring *ring, u8 *data, ring_size_t size)
{
s32 i;
@ -101,6 +102,7 @@ s32 ring_read(struct ring *ring, u8 *data, ring_size_t size)
return -i;
}
*/
/******************************************************************************
* The example implementation
@ -111,7 +113,9 @@ s32 ring_read(struct ring *ring, u8 *data, ring_size_t size)
struct ring output_ring;
u8 output_ring_buffer[BUFFER_SIZE];
void clock_setup(void)
int _write(int file, char *ptr, int len);
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -123,7 +127,7 @@ void clock_setup(void)
RCC_APB2ENR_AFIOEN | RCC_APB2ENR_USART1EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Initialize output ring buffer. */
ring_init(&output_ring, output_ring_buffer, BUFFER_SIZE);
@ -154,7 +158,7 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
gpio_set(GPIOC, GPIO12);
@ -216,7 +220,7 @@ int _write(int file, char *ptr, int len)
return -1;
}
void systick_setup(void)
static void systick_setup(void)
{
/* 72MHz / 8 => 9000000 counts per second. */
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);

View File

@ -25,7 +25,9 @@
#include <stdio.h>
#include <errno.h>
void clock_setup(void)
int _write(int file, char *ptr, int len);
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -37,7 +39,7 @@ void clock_setup(void)
RCC_APB2ENR_AFIOEN | RCC_APB2ENR_USART1EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Setup GPIO pin GPIO_USART1_RE_TX on GPIO port B for transmit. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
@ -55,7 +57,7 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
gpio_set(GPIOC, GPIO12);

View File

@ -177,8 +177,8 @@ static int cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *
* even though it's optional in the CDC spec, and we don't
* advertise it in the ACM functional descriptor.
*/
char buf[10];
struct usb_cdc_notification *notif = (void *)buf;
char local_buf[10];
struct usb_cdc_notification *notif = (void *)local_buf;
/* We echo signals back to host as notification. */
notif->bmRequestType = 0xA1;
@ -186,8 +186,8 @@ static int cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *
notif->wValue = 0;
notif->wIndex = 0;
notif->wLength = 2;
buf[8] = req->wValue & 3;
buf[9] = 0;
local_buf[8] = req->wValue & 3;
local_buf[9] = 0;
// usbd_ep_write_packet(0x83, buf, 10);
return 1;
}

View File

@ -143,16 +143,24 @@ static void usbdfu_getstatus_complete(usbd_device *usbd_dev, struct usb_setup_da
if (prog.blocknum == 0) {
switch (prog.buf[0]) {
case CMD_ERASE:
flash_erase_page(*(u32 *)(prog.buf + 1));
{
u32 *dat = (u32 *)(prog.buf + 1);
flash_erase_page(*dat);
}
case CMD_SETADDR:
prog.addr = *(u32 *)(prog.buf + 1);
{
u32 *dat = (u32 *)(prog.buf + 1);
prog.addr = *dat;
}
}
} else {
u32 baseaddr = prog.addr + ((prog.blocknum - 2) *
dfu_function.wTransferSize);
for (i = 0; i < prog.len; i += 2)
for (i = 0; i < prog.len; i += 2) {
u16 *dat = (u16 *)(prog.buf + i);
flash_program_half_word(baseaddr + i,
*(u16 *)(prog.buf + i));
*dat);
}
}
flash_lock();

View File

@ -143,16 +143,24 @@ static void usbdfu_getstatus_complete(usbd_device *usbd_dev, struct usb_setup_da
if (prog.blocknum == 0) {
switch (prog.buf[0]) {
case CMD_ERASE:
flash_erase_page(*(u32 *)(prog.buf + 1));
{
u32 *dat = (u32 *)(prog.buf + 1);
flash_erase_page(*dat);
}
case CMD_SETADDR:
prog.addr = *(u32 *)(prog.buf + 1);
{
u32 *dat = (u32 *)(prog.buf + 1);
prog.addr = *dat;
}
}
} else {
u32 baseaddr = prog.addr + ((prog.blocknum - 2) *
dfu_function.wTransferSize);
for (i = 0; i < prog.len; i += 2)
for (i = 0; i < prog.len; i += 2) {
u16 *dat = (u16 *)(prog.buf + i);
flash_program_half_word(baseaddr + i,
*(u16 *)(prog.buf + i));
*dat);
}
}
flash_lock();

View File

@ -22,7 +22,7 @@
#include <libopencm3/stm32/f1/gpio.h>
/* Set STM32 to 72 MHz. */
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@ -30,7 +30,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO6/7 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ,

View File

@ -33,7 +33,9 @@
#define USART_CONSOLE USART2
void clock_setup(void)
int _write(int file, char *ptr, int len);
static void clock_setup(void)
{
rcc_clock_setup_in_hsi_out_24mhz();
/* Enable clocks for USART2 and DAC*/
@ -46,7 +48,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_ADC1EN);
}
void usart_setup(void)
static void usart_setup(void)
{
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_USART2_TX);
@ -87,7 +89,7 @@ int _write(int file, char *ptr, int len)
return -1;
}
void adc_setup(void)
static void adc_setup(void)
{
gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO0);
gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO1);
@ -113,7 +115,7 @@ void adc_setup(void)
adc_calibration(ADC1);
}
void dac_setup(void)
static void dac_setup(void)
{
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO5);
dac_disable(CHANNEL_2);
@ -122,7 +124,7 @@ void dac_setup(void)
dac_set_trigger_source(DAC_CR_TSEL2_SW);
}
u16 read_adc_naiive(u8 channel)
static u16 read_adc_naiive(u8 channel)
{
u8 channel_array[16];
channel_array[0] = channel;

View File

@ -24,12 +24,12 @@
u16 exti_line_state;
/* Set STM32 to 24 MHz. */
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_24mhz();
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOC clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
@ -39,7 +39,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO9);
}
void button_setup(void)
static void button_setup(void)
{
/* Enable GPIOA clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);

View File

@ -23,7 +23,7 @@
#include <libopencm3/stm32/f1/gpio.h>
/* Set STM32 to 24 MHz. */
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_24mhz();
@ -31,7 +31,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO8/9 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ,

View File

@ -20,7 +20,7 @@
#include <libopencm3/stm32/f1/rcc.h>
#include <libopencm3/stm32/f1/gpio.h>
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOC clock. */
/* Manually: */

View File

@ -25,7 +25,7 @@
#include <libopencm3/stm32/pwr.h>
#include <libopencm3/cm3/nvic.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_24mhz();
@ -37,7 +37,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART1EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Setup GPIO pin GPIO_USART1_TX/GPIO9 on GPIO port A for transmit. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
@ -59,7 +59,7 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO8 (in GPIO port C) to 'output push-pull'. */
/* This drives the blue LED on the STM32VLDISCOVERY. */
@ -67,7 +67,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO8);
}
void nvic_setup(void)
static void nvic_setup(void)
{
/* Without this the RTC interrupt routine will never be called. */
nvic_enable_irq(NVIC_RTC_IRQ);

View File

@ -21,7 +21,7 @@
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/usart.h>
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_24mhz();
@ -33,7 +33,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART1EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Setup GPIO pin GPIO_USART1_TX/GPIO9 on GPIO port A for transmit. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
@ -55,7 +55,7 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO9 (in GPIO port C) to 'output push-pull'. [LED] */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ,

View File

@ -21,7 +21,7 @@
#include <libopencm3/stm32/f2/rcc.h>
#include <libopencm3/stm32/f2/gpio.h>
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOC clock. */
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPCEN);

View File

@ -26,7 +26,9 @@
#include <libopencm3/stm32/f2/gpio.h>
#include <libopencm3/stm32/f2/rcc.h>
void clock_setup(void)
int _write(int file, char *ptr, int len);
static void clock_setup(void)
{
/* Enable clocks on all the peripherals we are going to use. */
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_SPI2EN);
@ -35,7 +37,7 @@ void clock_setup(void)
RCC_AHB1ENR_IOPCEN | RCC_AHB1ENR_IOPAEN | RCC_AHB1ENR_IOPBEN);
}
void spi_setup(void)
static void spi_setup(void)
{
gpio_mode_setup(GPIOB, GPIO_MODE_AF, GPIO_PUPD_NONE,
GPIO13 | GPIO14 | GPIO15);
@ -50,7 +52,7 @@ void spi_setup(void)
spi_enable(SPI2);
}
void usart_setup(void)
static void usart_setup(void)
{
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9);
gpio_set_af(GPIOA, GPIO_AF7, GPIO9 | GPIO10);
@ -67,7 +69,7 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
gpio_set(GPIOC, GPIO3);

View File

@ -25,7 +25,9 @@
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/stm32/f2/rcc.h>
void clock_setup(void)
int _write(int file, char *ptr, int len);
static void clock_setup(void)
{
/* Enable clocks on all the peripherals we are going to use. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART1EN);
@ -33,7 +35,7 @@ void clock_setup(void)
RCC_AHB1ENR_IOPCEN | RCC_AHB1ENR_IOPAEN);
}
void usart_setup(void)
static void usart_setup(void)
{
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9);
gpio_set_af(GPIOA, GPIO_AF7, GPIO9 | GPIO10);
@ -50,7 +52,7 @@ void usart_setup(void)
usart_enable(USART1);
}
void gpio_setup(void)
static void gpio_setup(void)
{
gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_MODE_OUTPUT, GPIO3);
gpio_set(GPIOC, GPIO3);

View File

@ -25,12 +25,12 @@
u16 exti_line_state;
/* Set STM32 to 168 MHz. */
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOD clock. */
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
@ -40,7 +40,7 @@ void gpio_setup(void)
GPIO_PUPD_NONE, GPIO12 | GPIO13 | GPIO14 | GPIO15);
}
void button_setup(void)
static void button_setup(void)
{
/* Enable GPIOA clock. */
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);

View File

@ -23,7 +23,7 @@
#include <libopencm3/stm32/f4/gpio.h>
/* Set STM32 to 168 MHz. */
void clock_setup(void)
static void clock_setup(void)
{
rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);
@ -31,7 +31,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Set GPIO12-15 (in GPIO port D) to 'output push-pull'. */
gpio_mode_setup(GPIOD, GPIO_MODE_OUTPUT,

View File

@ -23,7 +23,7 @@
#include <libopencm3/stm32/f4/gpio.h>
#include <libopencm3/stm32/usart.h>
void clock_setup(void)
static void clock_setup(void)
{
/* Enable high-speed clock at 120MHz */
rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_120MHZ]);
@ -36,7 +36,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Setup USART2 parameters. */
usart_set_baudrate(USART2, 38400);
@ -50,7 +50,7 @@ void usart_setup(void)
usart_enable(USART2);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Setup GPIO pin GPIO12 on GPIO port D for LED. */
gpio_mode_setup(GPIOD, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO12);

View File

@ -21,7 +21,7 @@
#include <libopencm3/stm32/f4/rcc.h>
#include <libopencm3/stm32/f4/gpio.h>
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOD clock. */
/* Manually: */

View File

@ -22,7 +22,7 @@
#include <libopencm3/stm32/f4/gpio.h>
#include <libopencm3/stm32/usart.h>
void clock_setup(void)
static void clock_setup(void)
{
/* Enable GPIOD clock for LED & USARTs. */
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
@ -32,7 +32,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Setup USART2 parameters. */
usart_set_baudrate(USART2, 38400);
@ -46,7 +46,7 @@ void usart_setup(void)
usart_enable(USART2);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Setup GPIO pin GPIO12 on GPIO port D for LED. */
gpio_mode_setup(GPIOD, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO12);

View File

@ -24,7 +24,7 @@
#include <libopencm3/stm32/usart.h>
#include <libopencm3/cm3/nvic.h>
void clock_setup(void)
static void clock_setup(void)
{
/* Enable GPIOD clock for LED & USARTs. */
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
@ -34,7 +34,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Enable the USART2 interrupt. */
nvic_enable_irq(NVIC_USART2_IRQ);
@ -65,7 +65,7 @@ void usart_setup(void)
usart_enable(USART2);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Setup GPIO pin GPIO12 on GPIO port D for LED. */
gpio_mode_setup(GPIOD, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO12);

View File

@ -36,12 +36,14 @@
static volatile struct state_t state;
int _write(int file, char *ptr, int len);
__attribute__((always_inline)) static inline void __WFI(void)
{
__asm volatile ("wfi");
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* green led for ticking, blue for button feedback */
gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_DISCO_GREEN_PIN);
@ -69,7 +71,7 @@ void BUTTON_DISCO_USER_isr(void)
}
}
void setup_buttons(void)
static void setup_buttons(void)
{
/* Enable EXTI0 interrupt. */
nvic_enable_irq(BUTTON_DISCO_USER_NVIC);
@ -83,7 +85,7 @@ void setup_buttons(void)
exti_enable_request(BUTTON_DISCO_USER_EXTI);
}
void usart_setup(void)
static void usart_setup(void)
{
usart_set_baudrate(USART_CONSOLE, 115200);
usart_set_databits(USART_CONSOLE, 8);
@ -123,7 +125,7 @@ int _write(int file, char *ptr, int len)
/*
* Free running ms timer.
*/
void setup_button_press_timer(void)
static void setup_button_press_timer(void)
{
timer_reset(TIMER_BUTTON_PRESS);
timer_set_prescaler(TIMER_BUTTON_PRESS, 3999); // 4Mhz/1000hz - 1
@ -131,7 +133,7 @@ void setup_button_press_timer(void)
timer_enable_counter(TIMER_BUTTON_PRESS);
}
int setup_rtc(void)
static int setup_rtc(void)
{
/* turn on power block to enable unlocking */
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_PWREN);
@ -180,7 +182,7 @@ int setup_rtc(void)
return 0;
}
int setup_rtc_wakeup(int period)
static int setup_rtc_wakeup(int period)
{
rtc_unlock();
@ -227,12 +229,12 @@ void rtc_wkup_isr(void)
state.rtc_ticked = true;
}
int process_state(volatile struct state_t *st)
static int process_state(volatile struct state_t *st)
{
if (st->rtc_ticked) {
st->rtc_ticked = 0;
printf("Tick: %x\n", (unsigned int) RTC_TR);
#if FULL_USER_EXPERIENCE
#if defined(FULL_USER_EXPERIENCE)
gpio_toggle(LED_DISCO_GREEN_PORT, LED_DISCO_GREEN_PIN);
#else
gpio_clear(LED_DISCO_GREEN_PORT, LED_DISCO_GREEN_PIN);
@ -251,7 +253,7 @@ int process_state(volatile struct state_t *st)
return 0;
}
void reset_clocks(void)
static void reset_clocks(void)
{
/* 4MHz MSI raw range 2*/
clock_scale_t myclock_config = {

View File

@ -31,7 +31,9 @@
static struct state_t state;
void clock_setup(void)
int _write(int file, char *ptr, int len);
static void clock_setup(void)
{
rcc_clock_setup_pll(&clock_config[CLOCK_VRANGE1_HSI_PLL_24MHZ]);
/* Lots of things on all ports... */
@ -47,7 +49,7 @@ void clock_setup(void)
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* green led for ticking, blue for button feedback */
gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_DISCO_GREEN_PIN);
@ -60,7 +62,7 @@ void gpio_setup(void)
gpio_set_af(GPIOA, GPIO_AF7, GPIO2);
}
void usart_setup(void)
static void usart_setup(void)
{
usart_set_baudrate(USART_CONSOLE, 115200);
usart_set_databits(USART_CONSOLE, 8);
@ -131,7 +133,7 @@ void tim6_isr(void)
* Another ms timer, this one used to generate an overflow interrupt at 1ms
* It is used to toggle leds and write tick counts
*/
void setup_tim6(void)
static void setup_tim6(void)
{
timer_reset(TIM6);
// 24Mhz / 10khz -1.
@ -148,7 +150,7 @@ void setup_tim6(void)
/*
* Free running ms timer.
*/
void setup_tim7(void)
static void setup_tim7(void)
{
timer_reset(TIM7);
timer_set_prescaler(TIM7, 23999); // 24Mhz/1000hz - 1
@ -156,7 +158,7 @@ void setup_tim7(void)
timer_enable_counter(TIM7);
}
void setup_buttons(void)
static void setup_buttons(void)
{
/* Enable EXTI0 interrupt. */
nvic_enable_irq(BUTTON_DISCO_USER_NVIC);

View File

@ -25,7 +25,7 @@
#define PORT_LED GPIOB
#define PIN_LED GPIO6
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOB clock. */
/* Manually: */

View File

@ -22,7 +22,7 @@
#include <libopencm3/stm32/l1/gpio.h>
#include <libopencm3/stm32/usart.h>
void clock_setup(void)
static void clock_setup(void)
{
/* We are running on MSI after boot. */
/* Enable GPIOD clock for LED & USARTs. */
@ -33,7 +33,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
}
void usart_setup(void)
static void usart_setup(void)
{
/* Setup USART2 parameters. */
usart_set_baudrate(USART2, 38400);
@ -47,7 +47,7 @@ void usart_setup(void)
usart_enable(USART2);
}
void gpio_setup(void)
static void gpio_setup(void)
{
/* Setup GPIO pin GPIO7 on GPIO port B for Green LED. */
gpio_mode_setup(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO7);

View File

@ -108,6 +108,8 @@ IRQ numbers -3 and -6 to -9 are reserved
/* --- NVIC functions ------------------------------------------------------ */
#define WEAK __attribute__ ((weak))
BEGIN_DECLS
void nvic_enable_irq(u8 irqn);
@ -120,6 +122,17 @@ u8 nvic_get_irq_enabled(u8 irqn);
void nvic_set_priority(u8 irqn, u8 priority);
void nvic_generate_software_interrupt(u16 irqn);
void WEAK reset_handler(void);
void WEAK nmi_handler(void);
void WEAK hard_fault_handler(void);
void WEAK mem_manage_handler(void);
void WEAK bus_fault_handler(void);
void WEAK usage_fault_handler(void);
void WEAK sv_call_handler(void);
void WEAK debug_monitor_handler(void);
void WEAK pend_sv_handler(void);
void WEAK sys_tick_handler(void);
END_DECLS
/**@}*/

View File

@ -34,17 +34,6 @@ void main(void);
void blocking_handler(void);
void null_handler(void);
void WEAK reset_handler(void);
void WEAK nmi_handler(void);
void WEAK hard_fault_handler(void);
void WEAK mem_manage_handler(void);
void WEAK bus_fault_handler(void);
void WEAK usage_fault_handler(void);
void WEAK sv_call_handler(void);
void WEAK debug_monitor_handler(void);
void WEAK pend_sv_handler(void);
void WEAK sys_tick_handler(void);
__attribute__ ((section(".vectors")))
vector_table_t vector_table = {
.initial_sp_value = &_stack,