diff options
author | Perry Hung <iperry@alum.mit.edu> | 2010-03-31 21:29:29 -0400 |
---|---|---|
committer | Perry Hung <iperry@alum.mit.edu> | 2010-03-31 21:29:29 -0400 |
commit | 25c7ba0ed78aea0a368bc178dd720a845dd515ac (patch) | |
tree | 86be2502247dc0dd831191ae219a62875daad97c | |
parent | 4e51e057bb5a8d6b3475d2202af8a2a2caf9ba7b (diff) | |
download | librambutan-25c7ba0ed78aea0a368bc178dd720a845dd515ac.tar.gz librambutan-25c7ba0ed78aea0a368bc178dd720a845dd515ac.zip |
Removed inttypes.h
Removed inttypes.h from libmaple. Will have another pass through to use
the standard libmaple types, but will come in another commit.
-rw-r--r-- | core/Print.cpp | 12 | ||||
-rw-r--r-- | core/Print.h | 13 | ||||
-rw-r--r-- | core/comm/HardwareSerial.cpp | 6 | ||||
-rw-r--r-- | core/comm/HardwareSerial.h | 6 | ||||
-rw-r--r-- | core/comm/HardwareUsb.cpp | 8 | ||||
-rw-r--r-- | core/comm/HardwareUsb.h | 8 | ||||
-rw-r--r-- | core/ext_interrupts.c | 10 | ||||
-rw-r--r-- | core/ext_interrupts.h | 5 | ||||
-rw-r--r-- | core/io.h | 9 | ||||
-rw-r--r-- | core/pwm.c | 2 | ||||
-rw-r--r-- | core/pwm.h | 2 | ||||
-rw-r--r-- | core/time.c | 10 | ||||
-rw-r--r-- | core/time.h | 6 | ||||
-rw-r--r-- | core/wiring.h | 4 | ||||
-rw-r--r-- | core/wiring_analog.c | 2 | ||||
-rw-r--r-- | core/wiring_digital.c | 6 | ||||
-rw-r--r-- | core/wiring_shift.c | 2 | ||||
-rw-r--r-- | libmaple/adc.h | 27 | ||||
-rw-r--r-- | libmaple/bootVect.h | 12 | ||||
-rw-r--r-- | libmaple/exti.c | 12 | ||||
-rw-r--r-- | libmaple/exti.h | 5 | ||||
-rw-r--r-- | libmaple/gpio.c | 4 | ||||
-rw-r--r-- | libmaple/nvic.c | 4 | ||||
-rw-r--r-- | libmaple/rcc.c | 18 | ||||
-rw-r--r-- | libmaple/rcc.h | 4 | ||||
-rw-r--r-- | libmaple/systick.c | 2 | ||||
-rw-r--r-- | libmaple/systick.h | 4 | ||||
-rw-r--r-- | libmaple/timers.c | 84 | ||||
-rw-r--r-- | libmaple/timers.h | 11 | ||||
-rw-r--r-- | libmaple/usart.c | 8 | ||||
-rw-r--r-- | libmaple/usb.c | 2 | ||||
-rw-r--r-- | libmaple/usb.h | 2 | ||||
-rw-r--r-- | libmaple/util.c | 8 | ||||
-rw-r--r-- | libmaple/util.h | 25 |
34 files changed, 168 insertions, 175 deletions
diff --git a/core/Print.cpp b/core/Print.cpp index efe3eef..da461ae 100644 --- a/core/Print.cpp +++ b/core/Print.cpp @@ -36,13 +36,13 @@ void Print::write(const char *str) } /* default implementation: may be overridden */ -void Print::write(const uint8_t *buffer, size_t size) +void Print::write(const uint8 *buffer, uint32 size) { while (size--) write(*buffer++); } -void Print::print(uint8_t b) +void Print::print(uint8 b) { this->write(b); } @@ -114,7 +114,7 @@ void Print::println(const char c[]) println(); } -void Print::println(uint8_t b) +void Print::println(uint8 b) { print(b); println(); @@ -158,7 +158,7 @@ void Print::println(double n) // Private Methods ///////////////////////////////////////////////////////////// -void Print::printNumber(unsigned long n, uint8_t base) +void Print::printNumber(unsigned long n, uint8 base) { unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. unsigned long i = 0; @@ -179,7 +179,7 @@ void Print::printNumber(unsigned long n, uint8_t base) 'A' + buf[i - 1] - 10)); } -void Print::printFloat(double number, uint8_t digits) +void Print::printFloat(double number, uint8 digits) { // Handle negative numbers if (number < 0.0) @@ -190,7 +190,7 @@ void Print::printFloat(double number, uint8_t digits) // Round correctly so that print(1.999, 2) prints as "2.00" double rounding = 0.5; - for (uint8_t i=0; i<digits; ++i) + for (uint8 i=0; i<digits; ++i) rounding /= 10.0; number += rounding; diff --git a/core/Print.h b/core/Print.h index a69e85d..b2f8647 100644 --- a/core/Print.h +++ b/core/Print.h @@ -20,7 +20,6 @@ #ifndef Print_h #define Print_h -#include <inttypes.h> #include <stdio.h> // for size_t #define DEC 10 @@ -32,15 +31,15 @@ class Print { private: - void printNumber(unsigned long, uint8_t); - void printFloat(double, uint8_t); + void printNumber(unsigned long, uint8); + void printFloat(double, uint8); public: - virtual void write(uint8_t) = 0; + virtual void write(uint8) = 0; virtual void write(const char *str); - virtual void write(const uint8_t *buffer, size_t size); + virtual void write(const uint8 *buffer, uint32 size); void print(char); void print(const char[]); - void print(uint8_t); + void print(uint8); void print(int); void print(unsigned int); void print(long); @@ -50,7 +49,7 @@ class Print void println(void); void println(char); void println(const char[]); - void println(uint8_t); + void println(uint8); void println(int); void println(unsigned int); void println(long); diff --git a/core/comm/HardwareSerial.cpp b/core/comm/HardwareSerial.cpp index 04d8d18..7a8fed9 100644 --- a/core/comm/HardwareSerial.cpp +++ b/core/comm/HardwareSerial.cpp @@ -44,14 +44,14 @@ #define USART3_RX_PORT GPIOB_BASE #define USART3_RX_PIN 11 -HardwareSerial::HardwareSerial(uint8_t usartNum) { +HardwareSerial::HardwareSerial(uint8 usartNum) { ASSERT(usartNum == 1 || usartNum == 2 || usartNum == 3); this->usartNum = usartNum; } -uint8_t HardwareSerial::read(void) { +uint8 HardwareSerial::read(void) { return usart_getc(usartNum); } @@ -64,7 +64,7 @@ void HardwareSerial::write(unsigned char ch) { usart_putc(usartNum, ch); } -void HardwareSerial::begin(uint32_t baud) { +void HardwareSerial::begin(uint32 baud) { ASSERT(!(baud > USART_MAX_BAUD)); /* Set appropriate pin modes */ diff --git a/core/comm/HardwareSerial.h b/core/comm/HardwareSerial.h index a3913f9..2c9c6b8 100644 --- a/core/comm/HardwareSerial.h +++ b/core/comm/HardwareSerial.h @@ -32,10 +32,10 @@ class HardwareSerial : public Print { private: uint8 usartNum; public: - HardwareSerial(uint8_t); - void begin(uint32_t); + HardwareSerial(uint8); + void begin(uint32); uint32 available(void); - uint8_t read(void); + uint8 read(void); void flush(void); virtual void write(unsigned char); using Print::write; diff --git a/core/comm/HardwareUsb.cpp b/core/comm/HardwareUsb.cpp index 269a68f..43438f1 100644 --- a/core/comm/HardwareUsb.cpp +++ b/core/comm/HardwareUsb.cpp @@ -34,8 +34,8 @@ HardwareUsb::HardwareUsb(void) { rx_buffer_offset_out = 0; } -uint8_t HardwareUsb::read(void) { - uint8_t outVal = rx_buffer[rx_buffer_offset_out++]; +uint8 HardwareUsb::read(void) { + uint8 outVal = rx_buffer[rx_buffer_offset_out++]; #if 1 if (rx_buffer_offset_out == rx_buffer_offset_in) { @@ -46,7 +46,7 @@ uint8_t HardwareUsb::read(void) { return outVal; } -uint8_t HardwareUsb::available(void) { +uint8 HardwareUsb::available(void) { ASSERT(rx_buffer_offset_out >= 0); // return rx_buffer_offset+1; // return usb_serialGetRecvLen(); @@ -70,7 +70,7 @@ void HardwareUsb::usb_rx_cb(void) { BootVectTable *vectTable = (BootVectTable*)(BOOTLOADER_VECT_TABLE); HardwareUsb *thisPtr = (HardwareUsb*) vectTable->usb_local_obj_ptr; - uint8_t numBytes = usb_serialGetRecvLen(); + uint8 numBytes = usb_serialGetRecvLen(); #if 0 /* ONE-SHOT-TO-READ Version (buffer cleared on next recv interrupt */ diff --git a/core/comm/HardwareUsb.h b/core/comm/HardwareUsb.h index b8733c1..a5ff191 100644 --- a/core/comm/HardwareUsb.h +++ b/core/comm/HardwareUsb.h @@ -33,13 +33,13 @@ class HardwareUsb : public Print { static void usb_rx_cb(void); static void usb_tx_cb(void); unsigned char rx_buffer[USB_SERIAL_BUF_SIZE]; - int8_t rx_buffer_offset_out; - int8_t rx_buffer_offset_in; + int8 rx_buffer_offset_out; + int8 rx_buffer_offset_in; public: HardwareUsb(void); void begin(); - uint8_t available(void); - uint8_t read(void); + uint8 available(void); + uint8 read(void); void flush(void); virtual void write(unsigned char); using Print::write; diff --git a/core/ext_interrupts.c b/core/ext_interrupts.c index 20ec11f..e5919f4 100644 --- a/core/ext_interrupts.c +++ b/core/ext_interrupts.c @@ -28,8 +28,8 @@ #include "ext_interrupts.h" typedef struct ExtiInfo { - uint8_t channel; - uint8_t port; + uint8 channel; + uint8 port; } ExtiInfo; static ExtiInfo PIN_TO_EXTI_CHANNEL[NR_MAPLE_PINS] = { @@ -60,8 +60,8 @@ static ExtiInfo PIN_TO_EXTI_CHANNEL[NR_MAPLE_PINS] = { * * @sideeffect Registers a handler */ -int attachInterrupt(uint8_t pin, voidFuncPtr handler, ExtInterruptTriggerMode mode) { - uint8_t outMode; +int attachInterrupt(uint8 pin, voidFuncPtr handler, ExtInterruptTriggerMode mode) { + uint8 outMode; /* Parameter checking */ if (pin >= NR_MAPLE_PINS) { return EXT_INTERRUPT_INVALID_PIN; @@ -94,7 +94,7 @@ int attachInterrupt(uint8_t pin, voidFuncPtr handler, ExtInterruptTriggerMode mo return 0; } -int detachInterrupt(uint8_t pin) { +int detachInterrupt(uint8 pin) { if (!(pin < NR_MAPLE_PINS)) { return EXT_INTERRUPT_INVALID_PIN; } diff --git a/core/ext_interrupts.h b/core/ext_interrupts.h index d0e6365..d9e773e 100644 --- a/core/ext_interrupts.h +++ b/core/ext_interrupts.h @@ -37,15 +37,14 @@ enum ExtInterruptError { EXT_INTERRUPT_INVALID_PIN = (-1), EXT_INTERRUPT_INVALID_FUNCTION = (-2), EXT_INTERRUPT_INVALID_MODE = (-3), - }; #ifdef __cplusplus extern "C"{ #endif -int attachInterrupt(uint8_t pin, voidFuncPtr, ExtInterruptTriggerMode mode); -int detachInterrupt(uint8_t pin); +int attachInterrupt(uint8 pin, voidFuncPtr, ExtInterruptTriggerMode mode); +int detachInterrupt(uint8 pin); #ifdef __cplusplus } @@ -26,7 +26,6 @@ #ifndef _IO_H #define _IO_H -#include <inttypes.h> #include "gpio.h" #include "adc.h" @@ -110,7 +109,7 @@ typedef struct PinMapping { * OUTPUT_OPEN_DRAIN * } */ -void pinMode(uint8_t, uint8_t); +void pinMode(uint8, uint8); /* * Writes VALUE to digital pin[0-38] @@ -118,21 +117,21 @@ void pinMode(uint8_t, uint8_t); * pin -> {0-38, D0-D39, A0-16} * value -> LOW, HIGH; */ -void digitalWrite(uint8_t, uint8_t); +void digitalWrite(uint8, uint8); /* Read a digital value from pin, the pin mode must be set to * {INPUT, INPUT_PULLUP, INPUT_PULLDOWN} * digitalRead(pin) * pin -> {0-38, D0-D39, A0-16} */ -uint32_t digitalRead(uint8_t); +uint32 digitalRead(uint8); /* Read an analog value from pin, the pin mode must be set * to INPUT_ANALOG * analogRead(pin) * pin -> {A0-A16} * */ -uint32_t analogRead(uint8_t); +uint32 analogRead(uint8); #ifdef __cplusplus } // extern "C" @@ -30,7 +30,7 @@ extern const PinMapping PIN_MAP[NR_MAPLE_PINS]; -void pwmWrite(uint8_t pin, uint16_t duty_cycle) { +void pwmWrite(uint8 pin, uint16 duty_cycle) { TimerCCR ccr; if (pin >= NR_MAPLE_PINS) { @@ -30,7 +30,7 @@ extern "C"{ #endif -void pwmWrite(uint8_t, uint16_t); +void pwmWrite(uint8, uint16); #ifdef __cplusplus } diff --git a/core/time.c b/core/time.c index 164d978..4e20908 100644 --- a/core/time.c +++ b/core/time.c @@ -30,9 +30,9 @@ #define CYCLES_PER_MICROSECOND 72 #define FUDGE 42 -extern volatile uint32_t systick_timer_millis; +extern volatile uint32 systick_timer_millis; -unsigned long millis() { +uint32 millis() { unsigned long m; m = systick_timer_millis; return m; @@ -49,9 +49,9 @@ void delay(unsigned long ms) #if 1 -void delayMicroseconds(uint32_t us) { - uint32_t target; - uint32_t last, cur, count; +void delayMicroseconds(uint32 us) { + uint32 target; + uint32 last, cur, count; /* fudge factor hacky hack hack for function overhead */ target = us * CYCLES_PER_MICROSECOND - FUDGE; diff --git a/core/time.h b/core/time.h index 68b3901..377762c 100644 --- a/core/time.h +++ b/core/time.h @@ -30,16 +30,16 @@ extern "C"{ #endif /* Returns time since boot in milliseconds */ -uint32_t millis(void); +uint32 millis(void); /* Time in microseconds since boot */ -uint32_t micros(void); +uint32 micros(void); /* Delay for ms milliseconds */ void delay(unsigned long ms); /* Delay for us microseconds */ -void delayMicroseconds(uint32_t us); +void delayMicroseconds(uint32 us); #if 0 static inline void delay_us(uint32 us) { diff --git a/core/wiring.h b/core/wiring.h index bcf6eda..82ff41a 100644 --- a/core/wiring.h +++ b/core/wiring.h @@ -45,8 +45,8 @@ typedef uint8 boolean; typedef uint8 byte; void init(void); -unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); -void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val); +unsigned long pulseIn(uint8 pin, uint8 state, unsigned long timeout); +void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, byte val); #ifdef __cplusplus diff --git a/core/wiring_analog.c b/core/wiring_analog.c index d7d7150..af042a7 100644 --- a/core/wiring_analog.c +++ b/core/wiring_analog.c @@ -31,7 +31,7 @@ extern const PinMapping PIN_MAP[NR_MAPLE_PINS]; /* Assumes that the ADC has been initialized and * that the pin is set to ANALOG_INPUT */ -uint32_t analogRead(uint8_t pin) { +uint32 analogRead(uint8 pin) { if (pin >= NR_ANALOG_PINS) return 0; diff --git a/core/wiring_digital.c b/core/wiring_digital.c index 71dae57..d05ac4a 100644 --- a/core/wiring_digital.c +++ b/core/wiring_digital.c @@ -88,7 +88,7 @@ const PinMapping PIN_MAP[NR_MAPLE_PINS] = { {GPIOC_BASE, 9, ADC_INVALID, TIMER_INVALID} // D38/PC9 }; -void pinMode(uint8_t pin, WiringPinMode mode) { +void pinMode(uint8 pin, WiringPinMode mode) { uint8 outputMode; if (pin >= NR_MAPLE_PINS) @@ -125,14 +125,14 @@ void pinMode(uint8_t pin, WiringPinMode mode) { } -uint32_t digitalRead(uint8_t pin) { +uint32 digitalRead(uint8 pin) { if (pin >= NR_MAPLE_PINS) return 0; return (PIN_MAP[pin].port->IDR & BIT(PIN_MAP[pin].pin)) ? 1 : 0; } -void digitalWrite(uint8_t pin, uint8_t val) { +void digitalWrite(uint8 pin, uint8 val) { if (pin >= NR_MAPLE_PINS) return; diff --git a/core/wiring_shift.c b/core/wiring_shift.c index 28c6dfc..a2487e7 100644 --- a/core/wiring_shift.c +++ b/core/wiring_shift.c @@ -24,7 +24,7 @@ #include "wiring.h" -void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val) +void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 val) { int i; diff --git a/libmaple/adc.h b/libmaple/adc.h index d554b02..8dc56ab 100644 --- a/libmaple/adc.h +++ b/libmaple/adc.h @@ -25,7 +25,6 @@ #ifndef _ADC_H_ #define _ADC_H_ -#include <inttypes.h> #include "util.h" #ifdef __cplusplus @@ -41,25 +40,25 @@ extern "C"{ /* We'll only use ADC1 for now... */ #define ADC_BASE 0x40012400 -#define ADC_SR *(volatile uint32_t*)(ADC_BASE + 0) -#define ADC_CR1 *(volatile uint32_t*)(ADC_BASE + 0x4) -#define ADC_CR2 *(volatile uint32_t*)(ADC_BASE + 0x8) -#define ADC_SMPR1 *(volatile uint32_t*)(ADC_BASE + 0xC) -#define ADC_SMPR2 *(volatile uint32_t*)(ADC_BASE + 0x10) -#define ADC_SQR1 *(volatile uint32_t*)(ADC_BASE + 0x2C) -#define ADC_SQR3 *(volatile uint32_t*)(ADC_BASE + 0x34) -#define ADC_DR *(volatile uint32_t*)(ADC_BASE + 0x4C) +#define ADC_SR *(volatile uint32*)(ADC_BASE + 0) +#define ADC_CR1 *(volatile uint32*)(ADC_BASE + 0x4) +#define ADC_CR2 *(volatile uint32*)(ADC_BASE + 0x8) +#define ADC_SMPR1 *(volatile uint32*)(ADC_BASE + 0xC) +#define ADC_SMPR2 *(volatile uint32*)(ADC_BASE + 0x10) +#define ADC_SQR1 *(volatile uint32*)(ADC_BASE + 0x2C) +#define ADC_SQR3 *(volatile uint32*)(ADC_BASE + 0x34) +#define ADC_DR *(volatile uint32*)(ADC_BASE + 0x4C) #define CR2_EXTSEL_SWSTART (0xE << 16) #define CR2_RSTCAL (BIT(3)) #define CR2_EXTTRIG (BIT(20)) /* Bit banded bits */ -#define CR2_ADON_BIT *(volatile uint32_t*)(BITBAND_PERI(ADC_BASE+0x8, 0)) -#define CR2_CAL_BIT *(volatile uint32_t*)(BITBAND_PERI(ADC_BASE+0x8, 2)) -#define CR2_RSTCAL_BIT *(volatile uint32_t*)(BITBAND_PERI(ADC_BASE+0x8, 3)) -#define CR2_SWSTART_BIT *(volatile uint32_t*)(BITBAND_PERI(ADC_BASE+0x8 + 2, 6)) -#define SR_EOC_BIT *(volatile uint32_t*)(BITBAND_PERI(ADC_BASE+0, 1)) +#define CR2_ADON_BIT *(volatile uint32*)(BITBAND_PERI(ADC_BASE+0x8, 0)) +#define CR2_CAL_BIT *(volatile uint32*)(BITBAND_PERI(ADC_BASE+0x8, 2)) +#define CR2_RSTCAL_BIT *(volatile uint32*)(BITBAND_PERI(ADC_BASE+0x8, 3)) +#define CR2_SWSTART_BIT *(volatile uint32*)(BITBAND_PERI(ADC_BASE+0x8 + 2, 6)) +#define SR_EOC_BIT *(volatile uint32*)(BITBAND_PERI(ADC_BASE+0, 1)) #define NR_ANALOG_PINS 16 diff --git a/libmaple/bootVect.h b/libmaple/bootVect.h index 5bcb42b..803da03 100644 --- a/libmaple/bootVect.h +++ b/libmaple/bootVect.h @@ -23,7 +23,7 @@ #ifndef _BOOTVECT_H_ #define _BOOTVECT_H_ -#define BOOTLOADER_VECT_TABLE ((uint32_t*)0x20000000) +#define BOOTLOADER_VECT_TABLE ((uint32*)0x20000000) #ifdef __cplusplus extern "C"{ @@ -35,12 +35,12 @@ typedef struct { FuncPtr serial_tx_cb; FuncPtr serial_rx_cb; FuncPtr serial_linecoding_cb; - uint32_t* serial_count_in; - uint32_t* serial_count_out; - uint8_t* serial_buffer_out; + uint32* serial_count_in; + uint32* serial_count_out; + uint8* serial_buffer_out; void* linecoding; - uint8_t major_rev; - uint8_t minor_rev; + uint8 major_rev; + uint8 minor_rev; void* usb_device_ptr; void* usb_local_obj_ptr; } BootVectTable; diff --git a/libmaple/exti.c b/libmaple/exti.c index bdaa204..e5024b7 100644 --- a/libmaple/exti.c +++ b/libmaple/exti.c @@ -98,8 +98,8 @@ void EXTI4_IRQHandler(void) { void EXTI9_5_IRQHandler(void) { /* Figure out which channel it came from */ - uint32_t pending; - uint32_t i; + uint32 pending; + uint32 i; pending = REG_GET(EXTI_PR); pending = GET_BITS(pending, 5, 9); @@ -116,8 +116,8 @@ void EXTI9_5_IRQHandler(void) { void EXTI15_10_IRQHandler(void) { /* Figure out which channel it came from */ - uint32_t pending; - uint32_t i; + uint32 pending; + uint32 i; pending = REG_GET(EXTI_PR); pending = GET_BITS(pending, 10, 15); @@ -133,7 +133,7 @@ void EXTI15_10_IRQHandler(void) { } -void exti_attach_interrupt(uint8_t channel, uint8_t port, voidFuncPtr handler, uint8_t mode) { +void exti_attach_interrupt(uint8 channel, uint8 port, voidFuncPtr handler, uint8 mode) { ASSERT(channel < NR_EXTI_CHANNELS); ASSERT(port < NR_EXTI_PORTS); ASSERT(mode < NR_EXTI_MODES); @@ -227,7 +227,7 @@ void exti_attach_interrupt(uint8_t channel, uint8_t port, voidFuncPtr handler, u } -void exti_detach_interrupt(uint8_t channel) { +void exti_detach_interrupt(uint8 channel) { ASSERT(channel < NR_EXTI_CHANNELS); ASSERT(EXTI0 == 0); /* Is this interrupt actually on? */ diff --git a/libmaple/exti.h b/libmaple/exti.h index c728454..b4d9616 100644 --- a/libmaple/exti.h +++ b/libmaple/exti.h @@ -26,7 +26,6 @@ #ifndef _EXTI_H_ #define _EXTI_H_ -#include <inttypes.h> /* Notes: * * To generate the interrupt, the interrupt line should be configured and @@ -140,8 +139,8 @@ extern "C"{ #endif -void exti_attach_interrupt(uint8_t, uint8_t, voidFuncPtr, uint8_t); -void exti_detach_interrupt(uint8_t); +void exti_attach_interrupt(uint8, uint8, voidFuncPtr, uint8); +void exti_detach_interrupt(uint8); #ifdef __cplusplus } // extern "C" diff --git a/libmaple/gpio.c b/libmaple/gpio.c index 39341af..41d2e97 100644 --- a/libmaple/gpio.c +++ b/libmaple/gpio.c @@ -36,8 +36,8 @@ void gpio_init(void) { } void gpio_set_mode(GPIO_Port* port, uint8 gpio_pin, uint8 mode) { - uint32_t tmp; - uint32_t shift = POS(gpio_pin % 8); + uint32 tmp; + uint32 shift = POS(gpio_pin % 8); GPIOReg CR; ASSERT(port); diff --git a/libmaple/nvic.c b/libmaple/nvic.c index 45c1902..e480daf 100644 --- a/libmaple/nvic.c +++ b/libmaple/nvic.c @@ -37,8 +37,8 @@ void nvic_disable_interrupts(void) { } -void nvic_set_vector_table(uint32_t *addr, uint32_t offset) { - __write(SCB_VTOR, (uint32_t)addr | (offset & 0x1FFFFF80)); +void nvic_set_vector_table(uint32 *addr, uint32 offset) { + __write(SCB_VTOR, (uint32)addr | (offset & 0x1FFFFF80)); } diff --git a/libmaple/rcc.c b/libmaple/rcc.c index 98b115a..cb2005f 100644 --- a/libmaple/rcc.c +++ b/libmaple/rcc.c @@ -9,8 +9,8 @@ #include "flash.h" #include "rcc.h" -static void set_ahb_prescaler(uint32_t divider) { - uint32_t cfgr = __read(RCC_CFGR); +static void set_ahb_prescaler(uint32 divider) { + uint32 cfgr = __read(RCC_CFGR); cfgr &= ~HPRE; @@ -25,8 +25,8 @@ static void set_ahb_prescaler(uint32_t divider) { __write(RCC_CFGR, cfgr); } -static void set_apb1_prescaler(uint32_t divider) { - uint32_t cfgr = __read(RCC_CFGR); +static void set_apb1_prescaler(uint32 divider) { + uint32 cfgr = __read(RCC_CFGR); cfgr &= ~PPRE1; @@ -41,8 +41,8 @@ static void set_apb1_prescaler(uint32_t divider) { __write(RCC_CFGR, cfgr); } -static void set_apb2_prescaler(uint32_t divider) { - uint32_t cfgr = __read(RCC_CFGR); +static void set_apb2_prescaler(uint32 divider) { + uint32 cfgr = __read(RCC_CFGR); cfgr &= ~PPRE2; @@ -59,7 +59,7 @@ static void set_apb2_prescaler(uint32_t divider) { /* FIXME: magic numbers */ static void pll_init(void) { - uint32_t cfgr; + uint32 cfgr; cfgr = __read(RCC_CFGR); cfgr &= (~PLLMUL | PLL_INPUT_CLK_HSE); @@ -106,8 +106,8 @@ void rcc_init(void) { pll_init(); } -void rcc_set_adc_prescaler(uint32_t divider) { - uint32_t cfgr = __read(RCC_CFGR); +void rcc_set_adc_prescaler(uint32 divider) { + uint32 cfgr = __read(RCC_CFGR); cfgr &= ~ADCPRE; __write(RCC_CFGR, cfgr | PCLK2_DIV_2); } diff --git a/libmaple/rcc.h b/libmaple/rcc.h index 5c9591b..2af64e2 100644 --- a/libmaple/rcc.h +++ b/libmaple/rcc.h @@ -22,7 +22,7 @@ #define RCC_CFGR2 (RCC_BASE + 0x2C)) #define HSEON BIT(16) -#define HSERDY *(volatile uint32_t*)(BITBAND_PERI(RCC_CR + 2, 0)) +#define HSERDY *(volatile uint32*)(BITBAND_PERI(RCC_CR + 2, 0)) #define ADCPRE 0x0000C000 #define HPRE 0x000000F0 @@ -100,7 +100,7 @@ void rcc_init(void); -void rcc_set_adc_prescaler(uint32_t divider); +void rcc_set_adc_prescaler(uint32 divider); #endif diff --git a/libmaple/systick.c b/libmaple/systick.c index 47be69e..70548c5 100644 --- a/libmaple/systick.c +++ b/libmaple/systick.c @@ -28,7 +28,7 @@ #define MILLIS_INC 1 -volatile uint32_t systick_timer_millis = 0; +volatile uint32 systick_timer_millis = 0; void systick_init(void) { /* Set the reload counter to tick every 1ms */ diff --git a/libmaple/systick.h b/libmaple/systick.h index 61789c4..79861be 100644 --- a/libmaple/systick.h +++ b/libmaple/systick.h @@ -50,8 +50,8 @@ extern "C"{ void systick_init(void); -static inline uint32_t systick_get_count(void) { - return (uint32_t)*(volatile uint32*)SYSTICK_CNT; +static inline uint32 systick_get_count(void) { + return (uint32)*(volatile uint32*)SYSTICK_CNT; } #ifdef __cplusplus diff --git a/libmaple/timers.c b/libmaple/timers.c index e187428..c996f64 100644 --- a/libmaple/timers.c +++ b/libmaple/timers.c @@ -28,51 +28,51 @@ #include "timers.h" typedef struct { - volatile uint16_t CR1; - uint16_t RESERVED0; - volatile uint16_t CR2; - uint16_t RESERVED1; - volatile uint16_t SMCR; - uint16_t RESERVED2; - volatile uint16_t DIER; - uint16_t RESERVED3; - volatile uint16_t SR; - uint16_t RESERVED4; - volatile uint16_t EGR; - uint16_t RESERVED5; - volatile uint16_t CCMR1; - uint16_t RESERVED6; - volatile uint16_t CCMR2; - uint16_t RESERVED7; - volatile uint16_t CCER; - uint16_t RESERVED8; - volatile uint16_t CNT; - uint16_t RESERVED9; - volatile uint16_t PSC; - uint16_t RESERVED10; - volatile uint16_t ARR; - uint16_t RESERVED11; - volatile uint16_t RCR; - uint16_t RESERVED12; - volatile uint16_t CCR1; - uint16_t RESERVED13; - volatile uint16_t CCR2; - uint16_t RESERVED14; - volatile uint16_t CCR3; - uint16_t RESERVED15; - volatile uint16_t CCR4; - uint16_t RESERVED16; - volatile uint16_t BDTR; // Not used in general purpose timers - uint16_t RESERVED17; // Not used in general purpose timers - volatile uint16_t DCR; - uint16_t RESERVED18; - volatile uint16_t DMAR; - uint16_t RESERVED19; + volatile uint16 CR1; + uint16 RESERVED0; + volatile uint16 CR2; + uint16 RESERVED1; + volatile uint16 SMCR; + uint16 RESERVED2; + volatile uint16 DIER; + uint16 RESERVED3; + volatile uint16 SR; + uint16 RESERVED4; + volatile uint16 EGR; + uint16 RESERVED5; + volatile uint16 CCMR1; + uint16 RESERVED6; + volatile uint16 CCMR2; + uint16 RESERVED7; + volatile uint16 CCER; + uint16 RESERVED8; + volatile uint16 CNT; + uint16 RESERVED9; + volatile uint16 PSC; + uint16 RESERVED10; + volatile uint16 ARR; + uint16 RESERVED11; + volatile uint16 RCR; + uint16 RESERVED12; + volatile uint16 CCR1; + uint16 RESERVED13; + volatile uint16 CCR2; + uint16 RESERVED14; + volatile uint16 CCR3; + uint16 RESERVED15; + volatile uint16 CCR4; + uint16 RESERVED16; + volatile uint16 BDTR; // Not used in general purpose timers + uint16 RESERVED17; // Not used in general purpose timers + volatile uint16 DCR; + uint16 RESERVED18; + volatile uint16 DMAR; + uint16 RESERVED19; } Timer; -void timer_init(uint8_t timer_num, uint16_t prescale) { +void timer_init(uint8 timer_num, uint16 prescale) { Timer *timer; - uint32_t is_advanced = 0; + uint32 is_advanced = 0; ASSERT(timer_num > 0 && timer_num <= 4); diff --git a/libmaple/timers.h b/libmaple/timers.h index 18b0afb..7702c63 100644 --- a/libmaple/timers.h +++ b/libmaple/timers.h @@ -73,13 +73,12 @@ #ifndef _TIMERS_H_ #define _TIMERS_H_ -#include <inttypes.h> #ifdef __cplusplus extern "C"{ #endif -typedef volatile uint32_t* TimerCCR; +typedef volatile uint32* TimerCCR; #define TIMER1_BASE 0x40012C00 #define TIMER2_BASE 0x40000000 @@ -111,11 +110,11 @@ typedef volatile uint32_t* TimerCCR; /* Turn on timer with prescale as the divisor - * void timer_init(uint32_t timer, uint16_t prescale) + * void timer_init(uint32 timer, uint16 prescale) * timer -> {1-4} * prescale -> {1-65535} * */ -void timer_init(uint8_t, uint16_t); +void timer_init(uint8, uint16); void timers_disable(void); void timers_disable_channel(uint8, uint8); @@ -124,7 +123,7 @@ void timers_disable_channel(uint8, uint8); * register for the pin cause it saves pwmWrite() a couple of * cycles. * - * void timer_pwm(uint8_t channel, uint8_t duty_cycle); + * void timer_pwm(uint8 channel, uint8 duty_cycle); * channel -> {TIMERx_CHn_CCR} * duty_cycle -> {0-65535} * @@ -132,7 +131,7 @@ void timers_disable_channel(uint8, uint8); * pin has been set to alternate function output * timer has been initialized */ -static inline void timer_pwm_write_ccr(TimerCCR CCR, uint16_t duty_cycle) { +static inline void timer_pwm_write_ccr(TimerCCR CCR, uint16 duty_cycle) { *CCR = duty_cycle; } diff --git a/libmaple/usart.c b/libmaple/usart.c index 545f64a..ec3d31b 100644 --- a/libmaple/usart.c +++ b/libmaple/usart.c @@ -78,20 +78,20 @@ typedef struct usart_port { void USART1_IRQHandler(void) { /* Read the data */ - ring_buf1.buf[ring_buf1.tail++] = (uint8_t)(((usart_port*)(USART1_BASE))->DR); + ring_buf1.buf[ring_buf1.tail++] = (uint8)(((usart_port*)(USART1_BASE))->DR); ring_buf1.tail %= USART_RECV_BUF_SIZE; } /* Don't overrun your buffer, seriously */ void USART2_IRQHandler(void) { /* Read the data */ - ring_buf2.buf[ring_buf2.tail++] = (uint8_t)(((usart_port*)(USART2_BASE))->DR); + ring_buf2.buf[ring_buf2.tail++] = (uint8)(((usart_port*)(USART2_BASE))->DR); ring_buf2.tail %= USART_RECV_BUF_SIZE; } /* Don't overrun your buffer, seriously */ void USART3_IRQHandler(void) { /* Read the data */ - ring_buf3.buf[ring_buf3.tail++] = (uint8_t)(((usart_port*)(USART3_BASE))->DR); + ring_buf3.buf[ring_buf3.tail++] = (uint8)(((usart_port*)(USART3_BASE))->DR); ring_buf3.tail %= USART_RECV_BUF_SIZE; } @@ -156,7 +156,7 @@ void usart_init(uint8 usart_num, uint32 baud) { fractional_part = integer_part - (100 * (tmp >> 4)); tmp |= (((fractional_part * 16) + 50) / 100) & ((uint8)0x0F); - port->BRR = (uint16_t)tmp; + port->BRR = (uint16)tmp; port->CR1 = USART_TE | // transmitter enable USART_RE | // receiver enable diff --git a/libmaple/usb.c b/libmaple/usb.c index 8826858..6b343e6 100644 --- a/libmaple/usb.c +++ b/libmaple/usb.c @@ -7,7 +7,7 @@ void usb_lpIRQHandler(void) { typedef void (*funcPtr)(void); - const uint32_t usbIsrAddr = *(uint32_t*)(USB_ISR_ADDR); + const uint32 usbIsrAddr = *(uint32*)(USB_ISR_ADDR); void (*ptrToUsbISR)(void) = (funcPtr) usbIsrAddr; ptrToUsbISR(); } diff --git a/libmaple/usb.h b/libmaple/usb.h index fa40123..a096b74 100644 --- a/libmaple/usb.h +++ b/libmaple/usb.h @@ -17,7 +17,7 @@ void usb_userToPMABufferCopy(uint8 *pbUsrBuf,uint16 wPMABufAddr,uint16 wNBytes) void usb_PMAToUserBufferCopy(uint8 *pbUsrBuf,uint16 wPMABufAddr,uint16 wNBytes); void usb_serialWriteStr(const char *outStr); void usb_serialWriteChar(unsigned char ch); -uint8_t usb_serialGetRecvLen(); +uint8 usb_serialGetRecvLen(); void usb_copyRecvBuffer(unsigned char* dest, uint8 len); #ifdef __cplusplus diff --git a/libmaple/util.c b/libmaple/util.c index d323611..4984096 100644 --- a/libmaple/util.c +++ b/libmaple/util.c @@ -40,10 +40,10 @@ /* Error assert + fade */ void _fail(const char* file, int line, const char* exp) { - int32_t slope = 1; - int32_t CC = 0x0000; - int32_t TOP_CNT = 0x02FF; - int32_t i = 0; + int32 slope = 1; + uint32 CC = 0x0000; + uint32 TOP_CNT = 0x02FF; + uint32 i = 0; /* Turn off interrupts */ nvic_disable_interrupts(); diff --git a/libmaple/util.h b/libmaple/util.h index c1ba15d..b24c83b 100644 --- a/libmaple/util.h +++ b/libmaple/util.h @@ -26,7 +26,6 @@ /* Generally "useful" utility procedures */ #ifndef _UTIL_H_ #define _UTIL_H_ -#include <inttypes.h> #define MAPLE_DEBUG 1 @@ -34,7 +33,7 @@ #define BIT_MASK_SHIFT(mask, shift) ((mask) << (shift)) /* Return bits m to n of x */ -#define GET_BITS(x, m, n) ((((uint32_t)x) << (31 - (n))) >> ((31 - (n)) + (m))) +#define GET_BITS(x, m, n) ((((uint32)x) << (31 - (n))) >> ((31 - (n)) + (m))) /* Bit-banding macros */ #define BITBAND_SRAM_REF 0x20000000 @@ -46,20 +45,20 @@ #define COUNTFLAG *((volatile unsigned char*) (BITBAND_PERI(SYSTICK_CSR,2))) -#define REG_SET(reg, val) (*(volatile uint32_t*)(reg) = (val)) -#define REG_SET_BIT(reg, bit) (*(volatile uint32_t*)(reg) |= BIT(bit)) -#define REG_CLEAR_BIT(reg, bit) (*(volatile uint32_t*)(reg) &= ~BIT(bit)) -#define REG_SET_MASK(reg, mask) (*(volatile uint32_t*)(reg) |= (uint32_t)(mask)) -#define REG_CLEAR_MASK(reg, mask) (*(volatile uint32_t*)(reg) &= (uint32_t)~(mask)) +#define REG_SET(reg, val) (*(volatile uint32*)(reg) = (val)) +#define REG_SET_BIT(reg, bit) (*(volatile uint32*)(reg) |= BIT(bit)) +#define REG_CLEAR_BIT(reg, bit) (*(volatile uint32*)(reg) &= ~BIT(bit)) +#define REG_SET_MASK(reg, mask) (*(volatile uint32*)(reg) |= (uint32)(mask)) +#define REG_CLEAR_MASK(reg, mask) (*(volatile uint32*)(reg) &= (uint32)~(mask)) -#define REG_GET(reg) *(volatile uint32_t*)(reg) +#define REG_GET(reg) *(volatile uint32*)(reg) -#define __set_bits(addr, mask) *(volatile uint32_t*)(addr) |= (uint32_t)(mask) -#define __clear_bits(addr, mask) (*(volatile uint32_t*)(addr) &= (uint32_t)~(mask)) -#define __get_bits(addr, mask) (*(volatile uint32_t*)(addr) & (uint32_t)(mask)) +#define __set_bits(addr, mask) *(volatile uint32*)(addr) |= (uint32)(mask) +#define __clear_bits(addr, mask) (*(volatile uint32*)(addr) &= (uint32)~(mask)) +#define __get_bits(addr, mask) (*(volatile uint32*)(addr) & (uint32)(mask)) -#define __read(reg) *(volatile uint32_t*)(reg) -#define __write(reg, value) *(volatile uint32_t*)(reg) = (value) +#define __read(reg) *(volatile uint32*)(reg) +#define __write(reg, value) *(volatile uint32*)(reg) = (value) #ifdef __cplusplus extern "C"{ |