Updated to the new locm3 changed to stdint types.
This commit is contained in:
@@ -26,22 +26,22 @@
|
||||
#include <libopencm3/stm32/can.h>
|
||||
|
||||
struct can_tx_msg {
|
||||
u32 std_id;
|
||||
u32 ext_id;
|
||||
u8 ide;
|
||||
u8 rtr;
|
||||
u8 dlc;
|
||||
u8 data[8];
|
||||
uint32_t std_id;
|
||||
uint32_t ext_id;
|
||||
uint8_t ide;
|
||||
uint8_t rtr;
|
||||
uint8_t dlc;
|
||||
uint8_t data[8];
|
||||
};
|
||||
|
||||
struct can_rx_msg {
|
||||
u32 std_id;
|
||||
u32 ext_id;
|
||||
u8 ide;
|
||||
u8 rtr;
|
||||
u8 dlc;
|
||||
u8 data[8];
|
||||
u8 fmi;
|
||||
uint32_t std_id;
|
||||
uint32_t ext_id;
|
||||
uint8_t ide;
|
||||
uint8_t rtr;
|
||||
uint8_t dlc;
|
||||
uint8_t data[8];
|
||||
uint8_t fmi;
|
||||
};
|
||||
|
||||
struct can_tx_msg can_tx_msg;
|
||||
@@ -166,7 +166,7 @@ static void can_setup(void)
|
||||
void sys_tick_handler(void)
|
||||
{
|
||||
static int temp32 = 0;
|
||||
static u8 data[8] = {0, 1, 2, 0, 0, 0, 0, 0};
|
||||
static uint8_t data[8] = {0, 1, 2, 0, 0, 0, 0, 0};
|
||||
|
||||
/* We call this handler every 1ms so 100ms = 1s
|
||||
* Resulting in 100Hz message frequency.
|
||||
@@ -195,9 +195,9 @@ void sys_tick_handler(void)
|
||||
|
||||
void usb_lp_can_rx0_isr(void)
|
||||
{
|
||||
u32 id, fmi;
|
||||
uint32_t id, fmi;
|
||||
bool ext, rtr;
|
||||
u8 length, data[8];
|
||||
uint8_t length, data[8];
|
||||
|
||||
can_receive(CAN1, 0, false, &id, &ext, &rtr, &fmi, &length, data);
|
||||
|
||||
|
||||
@@ -164,10 +164,10 @@ static const char *usb_strings[] = {
|
||||
};
|
||||
|
||||
/* Buffer to be used for control requests. */
|
||||
u8 usbd_control_buffer[128];
|
||||
uint8_t usbd_control_buffer[128];
|
||||
|
||||
static int cdcacm_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 cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf,
|
||||
uint16_t *len, void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req))
|
||||
{
|
||||
(void)complete;
|
||||
(void)buf;
|
||||
@@ -203,7 +203,7 @@ static int cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cdcacm_data_rx_cb(usbd_device *usbd_dev, u8 ep)
|
||||
static void cdcacm_data_rx_cb(usbd_device *usbd_dev, uint8_t ep)
|
||||
{
|
||||
(void)ep;
|
||||
|
||||
@@ -219,7 +219,7 @@ static void cdcacm_data_rx_cb(usbd_device *usbd_dev, u8 ep)
|
||||
gpio_toggle(GPIOC, GPIO5);
|
||||
}
|
||||
|
||||
static void cdcacm_set_config(usbd_device *usbd_dev, u16 wValue)
|
||||
static void cdcacm_set_config(usbd_device *usbd_dev, uint16_t wValue)
|
||||
{
|
||||
(void)wValue;
|
||||
|
||||
|
||||
@@ -32,15 +32,15 @@
|
||||
#define CMD_ERASE 0x41
|
||||
|
||||
/* We need a special large control buffer for this device: */
|
||||
u8 usbd_control_buffer[1024];
|
||||
uint8_t usbd_control_buffer[1024];
|
||||
|
||||
static enum dfu_state usbdfu_state = STATE_DFU_IDLE;
|
||||
|
||||
static struct {
|
||||
u8 buf[sizeof(usbd_control_buffer)];
|
||||
u16 len;
|
||||
u32 addr;
|
||||
u16 blocknum;
|
||||
uint8_t buf[sizeof(usbd_control_buffer)];
|
||||
uint16_t len;
|
||||
uint32_t addr;
|
||||
uint16_t blocknum;
|
||||
} prog;
|
||||
|
||||
const struct usb_device_descriptor dev = {
|
||||
@@ -113,7 +113,7 @@ static const char *usb_strings[] = {
|
||||
"@Internal Flash /0x08000000/8*001Ka,56*001Kg",
|
||||
};
|
||||
|
||||
static u8 usbdfu_getstatus(u32 *bwPollTimeout)
|
||||
static uint8_t usbdfu_getstatus(uint32_t *bwPollTimeout)
|
||||
{
|
||||
switch (usbdfu_state) {
|
||||
case STATE_DFU_DNLOAD_SYNC:
|
||||
@@ -142,20 +142,20 @@ static void usbdfu_getstatus_complete(usbd_device *usbd_dev, struct usb_setup_da
|
||||
switch (prog.buf[0]) {
|
||||
case CMD_ERASE:
|
||||
{
|
||||
u32 *dat = (u32 *)(prog.buf + 1);
|
||||
uint32_t *dat = (uint32_t *)(prog.buf + 1);
|
||||
flash_erase_page(*dat);
|
||||
}
|
||||
case CMD_SETADDR:
|
||||
{
|
||||
u32 *dat = (u32 *)(prog.buf + 1);
|
||||
uint32_t *dat = (uint32_t *)(prog.buf + 1);
|
||||
prog.addr = *dat;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
u32 baseaddr = prog.addr + ((prog.blocknum - 2) *
|
||||
uint32_t baseaddr = prog.addr + ((prog.blocknum - 2) *
|
||||
dfu_function.wTransferSize);
|
||||
for (i = 0; i < prog.len; i += 2) {
|
||||
u16 *dat = (u16 *)(prog.buf + i);
|
||||
uint16_t *dat = (uint16_t *)(prog.buf + i);
|
||||
flash_program_half_word(baseaddr + i,
|
||||
*dat);
|
||||
}
|
||||
@@ -174,8 +174,8 @@ static void usbdfu_getstatus_complete(usbd_device *usbd_dev, struct usb_setup_da
|
||||
}
|
||||
}
|
||||
|
||||
static int usbdfu_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 usbdfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf,
|
||||
uint16_t *len, void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req))
|
||||
{
|
||||
(void)usbd_dev;
|
||||
|
||||
@@ -208,7 +208,7 @@ static int usbdfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *
|
||||
/* Upload not supported for now. */
|
||||
return 0;
|
||||
case DFU_GETSTATUS: {
|
||||
u32 bwPollTimeout = 0; /* 24-bit integer in DFU class spec */
|
||||
uint32_t bwPollTimeout = 0; /* 24-bit integer in DFU class spec */
|
||||
(*buf)[0] = usbdfu_getstatus(&bwPollTimeout);
|
||||
(*buf)[1] = bwPollTimeout & 0xFF;
|
||||
(*buf)[2] = (bwPollTimeout >> 8) & 0xFF;
|
||||
@@ -237,12 +237,12 @@ int main(void)
|
||||
|
||||
if (!gpio_get(GPIOA, GPIO10)) {
|
||||
/* Boot the application if it's valid. */
|
||||
if ((*(volatile u32 *)APP_ADDRESS & 0x2FFE0000) == 0x20000000) {
|
||||
if ((*(volatile uint32_t *)APP_ADDRESS & 0x2FFE0000) == 0x20000000) {
|
||||
/* Set vector table base address. */
|
||||
SCB_VTOR = APP_ADDRESS & 0xFFFF;
|
||||
/* Initialise master stack pointer. */
|
||||
asm volatile("msr msp, %0"::"g"
|
||||
(*(volatile u32 *)APP_ADDRESS));
|
||||
(*(volatile uint32_t *)APP_ADDRESS));
|
||||
/* Jump to application. */
|
||||
(*(void (**)())(APP_ADDRESS + 4))();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ const struct usb_device_descriptor dev_descr = {
|
||||
};
|
||||
|
||||
/* I have no idea what this means. I haven't read the HID spec. */
|
||||
static const u8 hid_report_descriptor[] = {
|
||||
static const uint8_t hid_report_descriptor[] = {
|
||||
0x05, 0x01, 0x09, 0x02, 0xA1, 0x01, 0x09, 0x01,
|
||||
0xA1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03,
|
||||
0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01,
|
||||
@@ -73,8 +73,8 @@ static const u8 hid_report_descriptor[] = {
|
||||
static const struct {
|
||||
struct usb_hid_descriptor hid_descriptor;
|
||||
struct {
|
||||
u8 bReportDescriptorType;
|
||||
u16 wDescriptorLength;
|
||||
uint8_t bReportDescriptorType;
|
||||
uint16_t wDescriptorLength;
|
||||
} __attribute__((packed)) hid_report;
|
||||
} __attribute__((packed)) hid_function = {
|
||||
.hid_descriptor = {
|
||||
@@ -176,9 +176,9 @@ static const char *usb_strings[] = {
|
||||
};
|
||||
|
||||
/* Buffer used for control requests. */
|
||||
u8 usbd_control_buffer[128];
|
||||
uint8_t usbd_control_buffer[128];
|
||||
|
||||
static int hid_control_request(usbd_device *dev, struct usb_setup_data *req, u8 **buf, u16 *len,
|
||||
static int hid_control_request(usbd_device *dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len,
|
||||
void (**complete)(usbd_device *dev, struct usb_setup_data *req))
|
||||
{
|
||||
(void)complete;
|
||||
@@ -190,7 +190,7 @@ static int hid_control_request(usbd_device *dev, struct usb_setup_data *req, u8
|
||||
return 0;
|
||||
|
||||
/* Handle the HID report descriptor. */
|
||||
*buf = (u8 *)hid_report_descriptor;
|
||||
*buf = (uint8_t *)hid_report_descriptor;
|
||||
*len = sizeof(hid_report_descriptor);
|
||||
|
||||
return 1;
|
||||
@@ -209,7 +209,7 @@ static void dfu_detach_complete(usbd_device *dev, struct usb_setup_data *req)
|
||||
scb_reset_core();
|
||||
}
|
||||
|
||||
static int dfu_control_request(usbd_device *dev, struct usb_setup_data *req, u8 **buf, u16 *len,
|
||||
static int dfu_control_request(usbd_device *dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len,
|
||||
void (**complete)(usbd_device *dev, struct usb_setup_data *req))
|
||||
{
|
||||
(void)buf;
|
||||
@@ -225,7 +225,7 @@ static int dfu_control_request(usbd_device *dev, struct usb_setup_data *req, u8
|
||||
}
|
||||
#endif
|
||||
|
||||
static void hid_set_config(usbd_device *dev, u16 wValue)
|
||||
static void hid_set_config(usbd_device *dev, uint16_t wValue)
|
||||
{
|
||||
(void)wValue;
|
||||
|
||||
@@ -251,7 +251,7 @@ static void hid_set_config(usbd_device *dev, u16 wValue)
|
||||
systick_counter_enable();
|
||||
}
|
||||
|
||||
static u8 spi_readwrite(u32 spi, u8 data)
|
||||
static uint8_t spi_readwrite(uint32_t spi, uint8_t data)
|
||||
{
|
||||
while (SPI_SR(spi) & SPI_SR_BSY)
|
||||
;
|
||||
@@ -261,9 +261,9 @@ static u8 spi_readwrite(u32 spi, u8 data)
|
||||
return SPI_DR(spi);
|
||||
}
|
||||
|
||||
static u8 accel_read(u8 addr)
|
||||
static uint8_t accel_read(uint8_t addr)
|
||||
{
|
||||
u8 ret;
|
||||
uint8_t ret;
|
||||
gpio_clear(GPIOB, GPIO12);
|
||||
spi_readwrite(SPI2, addr | 0x80);
|
||||
ret = spi_readwrite(SPI2, 0);
|
||||
@@ -271,7 +271,7 @@ static u8 accel_read(u8 addr)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void accel_write(u8 addr, u8 data)
|
||||
static void accel_write(uint8_t addr, uint8_t data)
|
||||
{
|
||||
gpio_clear(GPIOB, GPIO12);
|
||||
spi_readwrite(SPI2, addr);
|
||||
@@ -279,7 +279,7 @@ static void accel_write(u8 addr, u8 data)
|
||||
gpio_set(GPIOB, GPIO12);
|
||||
}
|
||||
|
||||
static void accel_get(s16 *x, s16 *y, s16 *z)
|
||||
static void accel_get(int16_t *x, int16_t *y, int16_t *z)
|
||||
{
|
||||
if (x)
|
||||
*x = accel_read(ADXL345_DATAX0) |
|
||||
@@ -361,8 +361,8 @@ int main(void)
|
||||
|
||||
void sys_tick_handler(void)
|
||||
{
|
||||
s16 x, y;
|
||||
u8 buf[4] = {0, 0, 0, 0};
|
||||
int16_t x, y;
|
||||
uint8_t buf[4] = {0, 0, 0, 0};
|
||||
|
||||
accel_get(&x, &y, NULL);
|
||||
buf[1] = x >> 9;
|
||||
|
||||
Reference in New Issue
Block a user