FIX: u{8,16,32} -> uint{8,16,32}_t to be compatible with new library

The use of u8, u16, u32 has been deprecated in libopencm3.
Update it with standard uint8_t, uint16_t, uint32_t types
This commit is contained in:
BuFran 2013-07-29 21:12:19 +02:00 committed by Gareth McMullin
parent f1584b266b
commit c28350f242
9 changed files with 45 additions and 45 deletions

View File

@ -190,23 +190,23 @@ void uart_usb_buf_drain(uint8_t ep);
#define vasprintf vasiprintf
#ifdef INLINE_GPIO
static inline void _gpio_set(u32 gpioport, u16 gpios)
static inline void _gpio_set(uint32_t gpioport, uint16_t gpios)
{
GPIO_BSRR(gpioport) = gpios;
GPIO_BSRR(gpioport) = gpios;
}
#define gpio_set _gpio_set
static inline void _gpio_clear(u32 gpioport, u16 gpios)
static inline void _gpio_clear(uint32_t gpioport, uint16_t gpios)
{
GPIO_BSRR(gpioport) = gpios<<16;
GPIO_BSRR(gpioport) = gpios<<16;
}
#define gpio_clear _gpio_clear
static inline u16 _gpio_get(u32 gpioport, u16 gpios)
static inline uint16_t _gpio_get(uint32_t gpioport, uint16_t gpios)
{
return (u16)GPIO_IDR(gpioport) & gpios;
return (uint16_t)GPIO_IDR(gpioport) & gpios;
}
#define gpio_get _gpio_get
#endif

View File

@ -263,15 +263,15 @@ const char *platform_target_voltage(void)
return gpio_get(GPIOB, GPIO0) ? "OK" : "ABSENT!";
static char ret[] = "0.0V";
const u8 channel = 8;
adc_set_regular_sequence(ADC1, 1, (u8*)&channel);
const uint8_t channel = 8;
adc_set_regular_sequence(ADC1, 1, (uint8_t*)&channel);
adc_start_conversion_direct(ADC1);
/* Wait for end of conversion. */
while (!adc_eoc(ADC1));
u32 val = adc_read_regular(ADC1) * 99; /* 0-4095 */
uint32_t val = adc_read_regular(ADC1) * 99; /* 0-4095 */
ret[0] = '0' + val / 81910;
ret[2] = '0' + (val / 8191) % 10;

View File

@ -193,21 +193,21 @@ void uart_usb_buf_drain(uint8_t ep);
#define vasprintf vasiprintf
#ifdef INLINE_GPIO
static inline void _gpio_set(u32 gpioport, u16 gpios)
static inline void _gpio_set(uint32_t gpioport, uint16_t gpios)
{
GPIO_BSRR(gpioport) = gpios;
}
#define gpio_set _gpio_set
static inline void _gpio_clear(u32 gpioport, u16 gpios)
static inline void _gpio_clear(uint32_t gpioport, uint16_t gpios)
{
GPIO_BRR(gpioport) = gpios;
}
#define gpio_clear _gpio_clear
static inline u16 _gpio_get(u32 gpioport, u16 gpios)
static inline uint16_t _gpio_get(uint32_t gpioport, uint16_t gpios)
{
return (u16)GPIO_IDR(gpioport) & gpios;
return (uint16_t)GPIO_IDR(gpioport) & gpios;
}
#define gpio_get _gpio_get
#endif

View File

@ -176,21 +176,21 @@ void uart_usb_buf_drain(uint8_t ep);
#define vasprintf vasiprintf
#ifdef INLINE_GPIO
static inline void _gpio_set(u32 gpioport, u16 gpios)
static inline void _gpio_set(uint32_t gpioport, uint16_t gpios)
{
GPIO_BSRR(gpioport) = gpios;
}
#define gpio_set _gpio_set
static inline void _gpio_clear(u32 gpioport, u16 gpios)
static inline void _gpio_clear(uint32_t gpioport, uint16_t gpios)
{
GPIO_BRR(gpioport) = gpios;
}
#define gpio_clear _gpio_clear
static inline u16 _gpio_get(u32 gpioport, u16 gpios)
static inline uint16_t _gpio_get(uint32_t gpioport, uint16_t gpios)
{
return (u16)GPIO_IDR(gpioport) & gpios;
return (uint16_t)GPIO_IDR(gpioport) & gpios;
}
#define gpio_get _gpio_get
#endif

View File

@ -480,7 +480,7 @@ int cdcacm_get_dtr(void)
return cdcacm_gdb_dtr;
}
static void cdcacm_set_config(usbd_device *dev, u16 wValue)
static void cdcacm_set_config(usbd_device *dev, uint16_t wValue)
{
configured = wValue;

View File

@ -48,7 +48,7 @@ void dfu_flash_program_buffer(uint32_t baseaddr, void *buf, int len)
{
for(int i = 0; i < len; i += 2)
flash_program_half_word(baseaddr + i,
*(u16*)(buf+i));
*(uint16_t*)(buf+i));
}
uint32_t dfu_poll_timeout(uint8_t cmd, uint32_t addr, uint16_t blocknum)
@ -77,12 +77,12 @@ void dfu_protect_enable(void)
void dfu_jump_app_if_valid(void)
{
/* 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 & 0x1FFFFF; /* Max 2 MByte Flash*/
/* 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))();
}

View File

@ -26,17 +26,17 @@
#include "usbdfu.h"
static u32 sector_addr[] = {0x8000000, 0x8004000, 0x8008000, 0x800c000,
static uint32_t sector_addr[] = {0x8000000, 0x8004000, 0x8008000, 0x800c000,
0x8010000, 0x8020000, 0x8040000, 0x8060000,
0x8080000, 0x80a0000, 0x80c0000, 0x80e0000,
0x8100000, 0};
static u16 sector_erase_time[12]= {500, 500, 500, 500,
static uint16_t sector_erase_time[12]= {500, 500, 500, 500,
1100,
2600, 2600, 2600, 2600, 2600, 2600, 2600};
static u8 sector_num = 0xff;
static uint8_t sector_num = 0xff;
/* Find the sector number for a given address*/
static void get_sector_num(u32 addr)
static void get_sector_num(uint32_t addr)
{
int i = 0;
while(sector_addr[i+1]) {
@ -60,7 +60,7 @@ void dfu_flash_program_buffer(uint32_t baseaddr, void *buf, int len)
{
for(int i = 0; i < len; i += 4)
flash_program_word(baseaddr + i,
*(u32*)(buf+i),
*(uint32_t*)(buf+i),
FLASH_PROGRAM_X32);
}
@ -93,12 +93,12 @@ void dfu_jump_app_if_valid(void)
/* Boot the application if it's valid */
/* Vector table may be anywhere in 128 kByte RAM
CCM not handled*/
if((*(volatile u32*)APP_ADDRESS & 0x2FFC0000) == 0x20000000) {
if((*(volatile uint32_t*)APP_ADDRESS & 0x2FFC0000) == 0x20000000) {
/* Set vector table base address */
SCB_VTOR = APP_ADDRESS & 0x1FFFFF; /* Max 2 MByte Flash*/
/* 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))();
}

View File

@ -34,19 +34,19 @@
usbd_device *usbdev;
/* We need a special large control buffer for this device: */
u8 usbd_control_buffer[1024];
uint8_t usbd_control_buffer[1024];
static u32 max_address;
static uint32_t max_address;
static enum dfu_state usbdfu_state = STATE_DFU_IDLE;
static char *get_dev_unique_id(char *serial_no);
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 = {
@ -121,13 +121,13 @@ static const char *usb_strings[] = {
DFU_IFACE_STRING,
};
static u32 get_le32(const void *vp)
static uint32_t get_le32(const void *vp)
{
const u8 *p = vp;
return ((u32)p[3] << 24) + ((u32)p[2] << 16) + (p[1] << 8) + p[0];
const uint8_t *p = vp;
return ((uint32_t)p[3] << 24) + ((uint32_t)p[2] << 16) + (p[1] << 8) + p[0];
}
static u8 usbdfu_getstatus(u32 *bwPollTimeout)
static uint8_t usbdfu_getstatus(uint32_t *bwPollTimeout)
{
switch(usbdfu_state) {
case STATE_DFU_DNLOAD_SYNC:
@ -157,7 +157,7 @@ usbdfu_getstatus_complete(usbd_device *dev, struct usb_setup_data *req)
flash_unlock();
if(prog.blocknum == 0) {
u32 addr = get_le32(prog.buf + 1);
uint32_t addr = get_le32(prog.buf + 1);
if (addr < APP_ADDRESS ||
(addr >= max_address)) {
flash_lock();
@ -171,7 +171,7 @@ usbdfu_getstatus_complete(usbd_device *dev, struct usb_setup_data *req)
prog.addr = addr;
}
} else {
u32 baseaddr = prog.addr +
uint32_t baseaddr = prog.addr +
((prog.blocknum - 2) *
dfu_function.wTransferSize);
dfu_flash_program_buffer(baseaddr, prog.buf, prog.len);
@ -193,7 +193,7 @@ usbdfu_getstatus_complete(usbd_device *dev, struct usb_setup_data *req)
}
static int usbdfu_control_request(usbd_device *dev,
struct usb_setup_data *req, u8 **buf, u16 *len,
struct usb_setup_data *req, uint8_t **buf, uint16_t *len,
void (**complete)(usbd_device *dev, struct usb_setup_data *req))
{
(void)dev;
@ -227,7 +227,7 @@ static int usbdfu_control_request(usbd_device *dev,
/* 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;
@ -292,7 +292,7 @@ static char *get_dev_unique_id(char *s)
/* Calculated the upper flash limit from the exported data
in theparameter block*/
max_address = (*(u32 *) FLASH_SIZE_R) <<10;
max_address = (*(uint32_t *) FLASH_SIZE_R) <<10;
/* Fetch serial number from chip's unique ID */
for(i = 0; i < 8; i++) {
s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';

View File

@ -174,21 +174,21 @@ void uart_usb_buf_drain(uint8_t ep);
#define vasprintf vasiprintf
#ifdef INLINE_GPIO
static inline void _gpio_set(u32 gpioport, u16 gpios)
static inline void _gpio_set(uint32_t gpioport, uint16_t gpios)
{
GPIO_BSRR(gpioport) = gpios;
}
#define gpio_set _gpio_set
static inline void _gpio_clear(u32 gpioport, u16 gpios)
static inline void _gpio_clear(uint32_t gpioport, uint16_t gpios)
{
GPIO_BRR(gpioport) = gpios;
}
#define gpio_clear _gpio_clear
static inline u16 _gpio_get(u32 gpioport, u16 gpios)
static inline uint16_t _gpio_get(uint32_t gpioport, uint16_t gpios)
{
return (u16)GPIO_IDR(gpioport) & gpios;
return (uint16_t)GPIO_IDR(gpioport) & gpios;
}
#define gpio_get _gpio_get
#endif