Updated to the new locm3 changed to stdint types.

This commit is contained in:
Piotr Esden-Tempski
2013-06-12 19:43:10 -07:00
parent adddf9e418
commit cb73d4ba3d
71 changed files with 443 additions and 443 deletions

View File

@@ -85,10 +85,10 @@ static void adc_setup(void)
adc_calibration(ADC1);
}
static void my_usart_print_int(u32 usart, int value)
static void my_usart_print_int(uint32_t usart, int value)
{
s8 i;
u8 nr_digits = 0;
int8_t i;
uint8_t nr_digits = 0;
char buffer[25];
if (value < 0) {
@@ -107,8 +107,8 @@ static void my_usart_print_int(u32 usart, int value)
int main(void)
{
u8 channel_array[16];
u16 temperature;
uint8_t channel_array[16];
uint16_t temperature;
rcc_clock_setup_in_hse_16mhz_out_72mhz();
gpio_setup();

View File

@@ -57,7 +57,7 @@ static void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO7);
}
static void my_usart_print_string(u32 usart, char *s)
static void my_usart_print_string(uint32_t usart, char *s)
{
while (*s != 0) {
usart_send(usart, *s);
@@ -107,10 +107,10 @@ int main(void)
dma_set_read_from_peripheral(DMA1, DMA_CHANNEL1);
/* We want to transfer string s1. */
dma_set_peripheral_address(DMA1, DMA_CHANNEL1, (u32)&s1);
dma_set_peripheral_address(DMA1, DMA_CHANNEL1, (uint32_t)&s1);
/* Destination should be string s2. */
dma_set_memory_address(DMA1, DMA_CHANNEL1, (u32)&s2);
dma_set_memory_address(DMA1, DMA_CHANNEL1, (uint32_t)&s2);
/*
* Set number of DATA to transfer.

View File

@@ -19,13 +19,13 @@
#include "./dogm128.h"
u8 dogm128_ram[1024];
u8 dogm128_cursor_x;
u8 dogm128_cursor_y;
uint8_t dogm128_ram[1024];
uint8_t dogm128_cursor_x;
uint8_t dogm128_cursor_y;
void dogm128_send_command(u8 command)
void dogm128_send_command(uint8_t command)
{
u32 i;
uint32_t i;
gpio_clear(DOGM128_A0_PORT, DOGM128_A0_PIN); /* A0 low for commands */
spi_send(DOGM128_SPI, command);
@@ -34,9 +34,9 @@ void dogm128_send_command(u8 command)
;
}
void dogm128_send_data(u8 data)
void dogm128_send_data(uint8_t data)
{
u32 i;
uint32_t i;
gpio_set(DOGM128_A0_PORT, DOGM128_A0_PIN); /* A0 high for data */
spi_send(DOGM128_SPI, data);
@@ -47,7 +47,7 @@ void dogm128_send_data(u8 data)
void dogm128_init(void)
{
u32 i;
uint32_t i;
/* Reset the display (reset low for dogm128). */
gpio_clear(DOGM128_RESET_PORT, DOGM128_RESET_PIN);
@@ -84,9 +84,9 @@ void dogm128_init(void)
spi_set_nss_high(DOGM128_SPI);
}
void dogm128_print_char(u8 data)
void dogm128_print_char(uint8_t data)
{
u8 i, page, shift, xcoord, ycoord;
uint8_t i, page, shift, xcoord, ycoord;
xcoord = dogm128_cursor_x;
ycoord = dogm128_cursor_y;
@@ -128,7 +128,7 @@ void dogm128_print_char(u8 data)
}
}
void dogm128_set_cursor(u8 xcoord, u8 ycoord)
void dogm128_set_cursor(uint8_t xcoord, uint8_t ycoord)
{
dogm128_cursor_x = xcoord;
dogm128_cursor_y = ycoord;
@@ -142,13 +142,13 @@ void dogm128_print_string(char *s)
}
}
void dogm128_set_dot(u8 xcoord, u8 ycoord)
void dogm128_set_dot(uint8_t xcoord, uint8_t ycoord)
{
dogm128_ram[(((63 - ycoord) / 8) * 128) + xcoord] |=
(1 << ((63 - ycoord) % 8));
}
void dogm128_clear_dot(u8 xcoord, u8 ycoord)
void dogm128_clear_dot(uint8_t xcoord, uint8_t ycoord)
{
dogm128_ram[(((63 - ycoord) / 8) * 128) + xcoord] &=
~(1 << ((63 - ycoord) % 8));
@@ -156,7 +156,7 @@ void dogm128_clear_dot(u8 xcoord, u8 ycoord)
void dogm128_update_display(void)
{
u8 page, column;
uint8_t page, column;
/* Tell the display that we want to start. */
spi_set_nss_low(DOGM128_SPI);
@@ -196,7 +196,7 @@ void dogm128_clear(void)
* little bit.
*/
const u8 dogm128_font[96][6] = {
const uint8_t dogm128_font[96][6] = {
/* 20 SPACE */ {0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA},
/* 21 ! */ {0x5E, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA},

View File

@@ -69,18 +69,18 @@
#define DOGM128_STATIC_INDICATOR_ON 0xAD
#define DOGM128_BOOSTER_RATIO_SET 0xF8
extern const u8 dogm128_font[96][6];
extern u8 dogm128_ram[1024];
extern u8 dogm128_cursor_x;
extern u8 dogm128_cursor_y;
extern const uint8_t dogm128_font[96][6];
extern uint8_t dogm128_ram[1024];
extern uint8_t dogm128_cursor_x;
extern uint8_t dogm128_cursor_y;
void dogm128_send_command(u8 command);
void dogm128_set_cursor(u8 xcoord, u8 ycoord);
void dogm128_print_char(u8 data);
void dogm128_send_command(uint8_t command);
void dogm128_set_cursor(uint8_t xcoord, uint8_t ycoord);
void dogm128_print_char(uint8_t data);
void dogm128_print_string(char *s);
void dogm128_set_dot(u8 xcoord, u8 ycoord);
void dogm128_clear_dot(u8 xcoord, u8 ycoord);
void dogm128_send_data(u8 data);
void dogm128_set_dot(uint8_t xcoord, uint8_t ycoord);
void dogm128_clear_dot(uint8_t xcoord, uint8_t ycoord);
void dogm128_send_data(uint8_t data);
void dogm128_init(void);
void dogm128_update_display(void);
void dogm128_clear(void);

View File

@@ -105,7 +105,7 @@ static void i2c_setup(void)
int main(void)
{
int i = 0;
u16 temperature;
uint16_t temperature;
rcc_clock_setup_in_hse_16mhz_out_72mhz();
gpio_setup();

View File

@@ -20,9 +20,9 @@
#include <libopencm3/stm32/i2c.h>
#include "stts75.h"
void stts75_write_config(u32 i2c, u8 sensor)
void stts75_write_config(uint32_t i2c, uint8_t sensor)
{
u32 reg32 __attribute__((unused));
uint32_t reg32 __attribute__((unused));
/* Send START condition. */
i2c_send_start(i2c);
@@ -51,9 +51,9 @@ void stts75_write_config(u32 i2c, u8 sensor)
i2c_send_stop(i2c);
}
void stts75_write_temp_os(u32 i2c, u8 sensor, u16 temp_os)
void stts75_write_temp_os(uint32_t i2c, uint8_t sensor, uint16_t temp_os)
{
u32 reg32 __attribute__((unused));
uint32_t reg32 __attribute__((unused));
/* Send START condition. */
i2c_send_start(i2c);
@@ -74,9 +74,9 @@ void stts75_write_temp_os(u32 i2c, u8 sensor, u16 temp_os)
/* Sending the data. */
i2c_send_data(i2c, 0x3); /* OvertemperatureShutdown register */
while (!(I2C_SR1(i2c) & I2C_SR1_BTF));
i2c_send_data(i2c, (u8)(temp_os >> 8)); /* MSB */
i2c_send_data(i2c, (uint8_t)(temp_os >> 8)); /* MSB */
while (!(I2C_SR1(i2c) & I2C_SR1_BTF));
i2c_send_data(i2c, (u8)(temp_os & 0xff00)); /* LSB */
i2c_send_data(i2c, (uint8_t)(temp_os & 0xff00)); /* LSB */
/* After the last byte we have to wait for TxE too. */
while (!(I2C_SR1(i2c) & (I2C_SR1_BTF | I2C_SR1_TxE)));
@@ -84,9 +84,9 @@ void stts75_write_temp_os(u32 i2c, u8 sensor, u16 temp_os)
i2c_send_stop(i2c);
}
void stts75_write_temp_hyst(u32 i2c, u8 sensor, u16 temp_hyst)
void stts75_write_temp_hyst(uint32_t i2c, uint8_t sensor, uint16_t temp_hyst)
{
u32 reg32 __attribute__((unused));
uint32_t reg32 __attribute__((unused));
/* Send START condition. */
i2c_send_start(i2c);
@@ -107,9 +107,9 @@ void stts75_write_temp_hyst(u32 i2c, u8 sensor, u16 temp_hyst)
/* Sending the data. */
i2c_send_data(i2c, 0x2); /* TemperatureHysteresis register */
while (!(I2C_SR1(i2c) & I2C_SR1_BTF));
i2c_send_data(i2c, (u8)(temp_hyst >> 8)); /* MSB */
i2c_send_data(i2c, (uint8_t)(temp_hyst >> 8)); /* MSB */
while (!(I2C_SR1(i2c) & I2C_SR1_BTF));
i2c_send_data(i2c, (u8)(temp_hyst & 0xff00)); /* LSB */
i2c_send_data(i2c, (uint8_t)(temp_hyst & 0xff00)); /* LSB */
/* After the last byte we have to wait for TxE too. */
while (!(I2C_SR1(i2c) & (I2C_SR1_BTF | I2C_SR1_TxE)));
@@ -117,10 +117,10 @@ void stts75_write_temp_hyst(u32 i2c, u8 sensor, u16 temp_hyst)
i2c_send_stop(i2c);
}
u16 stts75_read_temperature(u32 i2c, u8 sensor)
uint16_t stts75_read_temperature(uint32_t i2c, uint8_t sensor)
{
u32 reg32 __attribute__((unused));
u16 temperature;
uint32_t reg32 __attribute__((unused));
uint16_t temperature;
/* Send START condition. */
i2c_send_start(i2c);
@@ -172,7 +172,7 @@ u16 stts75_read_temperature(u32 i2c, u8 sensor)
/* Now the slave should begin to send us the first byte. Await BTF. */
while (!(I2C_SR1(i2c) & I2C_SR1_BTF));
temperature = (u16)(I2C_DR(i2c) << 8); /* MSB */
temperature = (uint16_t)(I2C_DR(i2c) << 8); /* MSB */
/*
* Yes they mean it: we have to generate the STOP condition before

View File

@@ -31,9 +31,9 @@
#define STTS75_SENSOR6 0x4e
#define STTS75_SENSOR7 0x4f
void stts75_write_config(u32 i2c, u8 sensor);
void stts75_write_temp_os(u32 i2c, u8 sensor, u16 temp_os);
void stts75_write_temp_hyst(u32 i2c, u8 sensor, u16 temp_hyst);
u16 stts75_read_temperature(u32 i2c, u8 sensor);
void stts75_write_config(uint32_t i2c, uint8_t sensor);
void stts75_write_temp_os(uint32_t i2c, uint8_t sensor, uint16_t temp_os);
void stts75_write_temp_hyst(uint32_t i2c, uint8_t sensor, uint16_t temp_hyst);
uint16_t stts75_read_temperature(uint32_t i2c, uint8_t sensor);
#endif

View File

@@ -70,7 +70,7 @@ static void nvic_setup(void)
void rtc_isr(void)
{
volatile u32 j = 0, c = 0;
volatile uint32_t j = 0, c = 0;
/* The interrupt flag isn't cleared by hardware, we have to do it. */
rtc_clear_flag(RTC_SEC);

View File

@@ -23,7 +23,7 @@
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/cm3/systick.h>
u32 temp32;
uint32_t temp32;
static void gpio_setup(void)
{

View File

@@ -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;
@@ -216,7 +216,7 @@ static void cdcacm_data_rx_cb(usbd_device *usbd_dev, u8 ep)
}
}
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;

View File

@@ -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))();
}

View File

@@ -53,7 +53,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,
@@ -69,8 +69,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 = {
@@ -172,9 +172,9 @@ 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 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 *, struct usb_setup_data *))
{
(void)complete;
@@ -186,7 +186,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;
@@ -205,7 +205,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 *, struct usb_setup_data *))
{
(void)buf;
@@ -221,7 +221,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;
(void)dev;
@@ -273,7 +273,7 @@ void sys_tick_handler(void)
{
static int x = 0;
static int dir = 1;
u8 buf[4] = {0, 0, 0, 0};
uint8_t buf[4] = {0, 0, 0, 0};
buf[1] = dir;
x += dir;