Fixed all warnings for examples.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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. */
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user