From c8da1c3b7b6eb450138a00af9bbbee607f596837 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Mon, 7 Mar 2011 13:11:54 -0500 Subject: [WIP] GPIO refactor: seems ok, ready for review --- libmaple/ring_buffer.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'libmaple/ring_buffer.h') diff --git a/libmaple/ring_buffer.h b/libmaple/ring_buffer.h index a44088e..f7baa6c 100644 --- a/libmaple/ring_buffer.h +++ b/libmaple/ring_buffer.h @@ -13,21 +13,20 @@ extern "C"{ #endif -/* The buffer is empty when head == tail. +/** + * Ring buffer type. + * + * The buffer is empty when head == tail. * * The buffer is full when the head is one byte in front of the tail, * modulo buffer length. * * One byte is left free to distinguish empty from full. */ typedef struct ring_buffer { - /** Buffer items are stored into */ - volatile uint8 *buf; - /** Index of the next item to remove */ - uint16 head; - /** Index where the next item will get inserted */ - uint16 tail; - /** Buffer capacity minus one */ - uint16 size; + volatile uint8 *buf; /**< Buffer items are stored into */ + uint16 head; /**< Index of the next item to remove */ + uint16 tail; /**< Index where the next item will get inserted */ + uint16 size; /**< Buffer capacity minus one */ } ring_buffer; /** -- cgit v1.2.3 From 7a7dff5186fa1b96f15c82672fc94432196d7eb5 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Thu, 17 Mar 2011 08:20:34 -0400 Subject: Adding rb_safe_remove() to ring_buffer.h --- libmaple/ring_buffer.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libmaple/ring_buffer.h') diff --git a/libmaple/ring_buffer.h b/libmaple/ring_buffer.h index f7baa6c..6e9b250 100644 --- a/libmaple/ring_buffer.h +++ b/libmaple/ring_buffer.h @@ -78,6 +78,17 @@ static inline uint8 rb_remove(ring_buffer *rb) { return ch; } +/** + * If the ring buffer is nonempty, removes and returns its first item. + * If it is empty, does nothing and returns a negative value. + */ +static inline int16 rb_safe_remove(ring_buffer *rb) { + if (rb_full_count(rb) == 0) { + return -1; + } + return rb_remove(rb); +} + /** * If rb is not full, appends element and returns true; otherwise, * does nothing and returns false. */ -- cgit v1.2.3 From 6245b43b26e47ece1927d28246611488c2f36e67 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Thu, 17 Mar 2011 09:10:28 -0400 Subject: Fixing inefficient rb_safe_remove() implementation; thanks, geoffreymbrown! --- libmaple/ring_buffer.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libmaple/ring_buffer.h') diff --git a/libmaple/ring_buffer.h b/libmaple/ring_buffer.h index 6e9b250..3b5d4e7 100644 --- a/libmaple/ring_buffer.h +++ b/libmaple/ring_buffer.h @@ -65,6 +65,11 @@ static inline int rb_is_full(ring_buffer *rb) { (rb->tail == rb->size && rb->head == 0); } +/** Return true if and only if the ring buffer is empty. */ +static inline int rb_is_empty(ring_buffer *rb) { + return rb->head == rb->tail; +} + /** Append element onto the end of the ring buffer. */ static inline void rb_insert(ring_buffer *rb, uint8 element) { rb->buf[rb->tail] = element; @@ -83,10 +88,7 @@ static inline uint8 rb_remove(ring_buffer *rb) { * If it is empty, does nothing and returns a negative value. */ static inline int16 rb_safe_remove(ring_buffer *rb) { - if (rb_full_count(rb) == 0) { - return -1; - } - return rb_remove(rb); + return rb_is_empty(rb) ? -1 : rb_remove(rb); } /** -- cgit v1.2.3 From 6bc8cb7c1181e8005019e4ce1f2bea956c44e044 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Thu, 17 Mar 2011 14:22:54 -0400 Subject: Adding license to ring_buffer.h --- libmaple/ring_buffer.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'libmaple/ring_buffer.h') diff --git a/libmaple/ring_buffer.h b/libmaple/ring_buffer.h index 3b5d4e7..eadb292 100644 --- a/libmaple/ring_buffer.h +++ b/libmaple/ring_buffer.h @@ -1,3 +1,29 @@ +/****************************************************************************** + * The MIT License + * + * Copyright (c) 2011 LeafLabs, LLC. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + *****************************************************************************/ + /** * @file ring_buffer.h * @brief Simple circular buffer -- cgit v1.2.3 From fb5a1612bcadf14460a88de08a065f4a5229f02f Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Mon, 4 Apr 2011 13:40:25 -0400 Subject: ring_buffer tweaks. Adding basic ring_buffer test (cherry-pick from master). Changing rb_safe_insert()'s type to match that of rb_push_insert(). (Makes it easier to pass around insertion functions.) --- examples/test-ring-buffer-insertion.cpp | 114 ++++++++++++++++++++++++++++++++ libmaple/ring_buffer.h | 8 ++- 2 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 examples/test-ring-buffer-insertion.cpp (limited to 'libmaple/ring_buffer.h') diff --git a/examples/test-ring-buffer-insertion.cpp b/examples/test-ring-buffer-insertion.cpp new file mode 100644 index 0000000..8372a96 --- /dev/null +++ b/examples/test-ring-buffer-insertion.cpp @@ -0,0 +1,114 @@ +/* + * Simple ring_buffer test. + * + * Does a basic test of functionality on rb_full_count(), rb_reset(), + * rb_push_insert(), and rb_safe_insert(). + * + * To test (no external hardware required): + * + * - Connect a serial monitor to SerialUSB + * - Press any key + * + * This file is released into the public domain. + */ + +#include "wirish.h" + +#include "ring_buffer.h" + +#define BUF_SIZE 64 +ring_buffer ring_buf; +ring_buffer *rb; +uint8 rb_buffer[BUF_SIZE]; + +void test_rb_push_insert(int num_bytes_to_insert); +void test_rb_safe_insert(int num_bytes_to_insert); +void test_rb_insertion_function(int num_bytes_to_insert, + int (*insertion_fn)(ring_buffer*, uint8), + const char insertion_fn_name[]); +void print_rb_contents(void); + +void setup() { + rb = &ring_buf; + rb_init(rb, BUF_SIZE, rb_buffer); + + while (!SerialUSB.available()) + ; + + SerialUSB.println("Beginning test."); + SerialUSB.println(); +} + +void loop() { + test_rb_push_insert(63); + SerialUSB.println("------------------------------"); + test_rb_push_insert(64); + SerialUSB.println("------------------------------"); + test_rb_safe_insert(63); + SerialUSB.println("------------------------------"); + test_rb_safe_insert(64); + SerialUSB.println("------------------------------"); + + SerialUSB.println(); + SerialUSB.println("Test finished."); + while (true) + ; +} + +void test_rb_push_insert(int num_bytes_to_insert) { + test_rb_insertion_function(num_bytes_to_insert, + rb_push_insert, + "rb_push_insert()"); +} + +void test_rb_safe_insert(int num_bytes_to_insert) { + test_rb_insertion_function(num_bytes_to_insert, + rb_safe_insert, + "rb_safe_insert()"); +} + +void test_rb_insertion_function(int num_bytes_to_insert, + int (*insertion_fn)(ring_buffer *, uint8), + const char insertion_fn_name[]) { + SerialUSB.println("resetting ring buffer."); + rb_reset(rb); + print_rb_contents(); + + SerialUSB.print(insertion_fn_name); + SerialUSB.print("-ing "); + SerialUSB.print(num_bytes_to_insert); + SerialUSB.println(" bytes."); + for (uint8 i = 1; i <= num_bytes_to_insert; i++) + insertion_fn(rb, i); + + uint16 count = rb_full_count(rb); + SerialUSB.print("rb_full_count(rb) = "); + SerialUSB.println(count); + + print_rb_contents(); +} + +void print_rb_contents() { + uint16 count = rb_full_count(rb); + SerialUSB.print("ring buffer contents: "); + for (uint16 i = 0; i < count; i++) { + SerialUSB.print((int)rb_remove(rb)); + if (i < count - 1) SerialUSB.print(", "); + } + SerialUSB.println(); +} + +// Force init to be called *first*, i.e. before static object allocation. +// Otherwise, statically allocated objects that need libmaple may fail. +__attribute__((constructor)) void premain() { + init(); +} + +int main(void) { + setup(); + + while (true) { + loop(); + } + return 0; +} diff --git a/libmaple/ring_buffer.h b/libmaple/ring_buffer.h index eadb292..9f35d3d 100644 --- a/libmaple/ring_buffer.h +++ b/libmaple/ring_buffer.h @@ -118,8 +118,12 @@ static inline int16 rb_safe_remove(ring_buffer *rb) { } /** - * If rb is not full, appends element and returns true; otherwise, - * does nothing and returns false. */ + * @brief Attempt to insert an element into a ring buffer. + * + * @brief rb Buffer to insert into. + * @brief element Value to insert into rb. + * @sideeffect If rb is not full, appends element onto buffer. + * @return If element was appended, then true; otherwise, false. */ static inline int rb_safe_insert(ring_buffer *rb, uint8 element) { if (rb_is_full(rb)) { return 0; -- cgit v1.2.3 From cf4322804a94ab81b057ec1c0e2f397338b5ab69 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Fri, 1 Apr 2011 01:16:35 -0400 Subject: ring_buffer.h function comments converted to Doxygen --- libmaple/ring_buffer.h | 52 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 14 deletions(-) (limited to 'libmaple/ring_buffer.h') diff --git a/libmaple/ring_buffer.h b/libmaple/ring_buffer.h index 9f35d3d..101f010 100644 --- a/libmaple/ring_buffer.h +++ b/libmaple/ring_buffer.h @@ -67,15 +67,17 @@ typedef struct ring_buffer { * * @param buf Buffer to store items into */ -__attribute__((unused)) -static void rb_init(ring_buffer *rb, uint16 size, uint8 *buf) { +static inline void rb_init(ring_buffer *rb, uint16 size, uint8 *buf) { rb->head = 0; rb->tail = 0; rb->size = size - 1; rb->buf = buf; } -/** Return the number of elements stored in the ring buffer. */ +/** + * @brief Return the number of elements stored in the ring buffer. + * @param rb Buffer whose elements to count. + */ static inline uint16 rb_full_count(ring_buffer *rb) { volatile ring_buffer *arb = rb; int32 size = arb->tail - arb->head; @@ -85,24 +87,37 @@ static inline uint16 rb_full_count(ring_buffer *rb) { return (uint16)size; } -/** Return true if and only if the ring buffer is full. */ +/** + * @brief Returns true if and only if the ring buffer is full. + * @brief rb Buffer to test. + */ static inline int rb_is_full(ring_buffer *rb) { return (rb->tail + 1 == rb->head) || (rb->tail == rb->size && rb->head == 0); } -/** Return true if and only if the ring buffer is empty. */ +/** + * @brief Returns true if and only if the ring buffer is empty. + * @param rb Buffer to test. + */ static inline int rb_is_empty(ring_buffer *rb) { return rb->head == rb->tail; } -/** Append element onto the end of the ring buffer. */ +/** + * Append element onto the end of a ring buffer. + * @param rb Buffer to append onto. + * @param element Value to append. + */ static inline void rb_insert(ring_buffer *rb, uint8 element) { rb->buf[rb->tail] = element; rb->tail = (rb->tail == rb->size) ? 0 : rb->tail + 1; } -/** Remove and return the first item from the ring buffer. */ +/** + * @brief Remove and return the first item from a ring buffer. + * @param rb Buffer to remove from, must contain at least one element. + */ static inline uint8 rb_remove(ring_buffer *rb) { uint8 ch = rb->buf[rb->head]; rb->head = (rb->head == rb->size) ? 0 : rb->head + 1; @@ -110,8 +125,12 @@ static inline uint8 rb_remove(ring_buffer *rb) { } /** + * @brief Attempt to remove the first item from a ring buffer. + * * If the ring buffer is nonempty, removes and returns its first item. * If it is empty, does nothing and returns a negative value. + * + * @param rb Buffer to attempt to remove from. */ static inline int16 rb_safe_remove(ring_buffer *rb) { return rb_is_empty(rb) ? -1 : rb_remove(rb); @@ -133,12 +152,16 @@ static inline int rb_safe_insert(ring_buffer *rb, uint8 element) { } /** - * Append an item onto the end of a non-full ring buffer. If the - * buffer is full, removes its first item, then inserts the new + * @brief Append an item onto the end of a non-full ring buffer. + * + * If the buffer is full, removes its first item, then inserts the new * element at the end. * - * On success, returns -1. If an element was popped, returns the - * popped value. */ + * @param rb Ring buffer to insert into. + * @param element Value to insert into ring buffer. + * @return On success, returns -1. If an element was popped, returns + * the popped value. + */ static inline int rb_push_insert(ring_buffer *rb, uint8 element) { int ret = -1; if (rb_is_full(rb)) { @@ -148,7 +171,10 @@ static inline int rb_push_insert(ring_buffer *rb, uint8 element) { return ret; } -/** Discard all items from the buffer */ +/** + * @brief Discard all items from a ring buffer. + * @param rb Ring buffer to discard all items from. + */ static inline void rb_reset(ring_buffer *rb) { rb->tail = rb->head; } @@ -157,7 +183,5 @@ static inline void rb_reset(ring_buffer *rb) { } // extern "C" #endif - - #endif -- cgit v1.2.3 From 7b14b950363f707c40732b4387f2f50711907673 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Tue, 12 Apr 2011 00:08:54 -0400 Subject: Doxygen bugfixes. Fixed various Doxygen comment errors. --- libmaple/adc.h | 1 + libmaple/bkp.h | 6 +++--- libmaple/dma.h | 4 ++++ libmaple/ring_buffer.h | 6 +++--- libmaple/timer.h | 9 +++++---- wirish/pwm.h | 3 +++ wirish/wirish_time.h | 2 +- wirish/wirish_types.h | 3 +++ 8 files changed, 23 insertions(+), 11 deletions(-) (limited to 'libmaple/ring_buffer.h') diff --git a/libmaple/adc.h b/libmaple/adc.h index 520b982..c6a67a0 100644 --- a/libmaple/adc.h +++ b/libmaple/adc.h @@ -309,6 +309,7 @@ uint16 adc_read(const adc_dev *dev, uint8 channel); * Defines the total number of conversions in the regular channel * conversion sequence. * + * @param dev ADC device. * @param length Regular channel sequence length, from 1 to 16. */ static inline void adc_set_reg_seqlen(const adc_dev *dev, uint8 length) { diff --git a/libmaple/bkp.h b/libmaple/bkp.h index cea39b6..97edd2a 100644 --- a/libmaple/bkp.h +++ b/libmaple/bkp.h @@ -46,7 +46,7 @@ extern "C" { /** Backup peripheral register map type. */ typedef struct bkp_reg_map { - const uint32 RESERVED1; + const uint32 RESERVED1; ///< Reserved __io uint32 DR1; ///< Data register 1 __io uint32 DR2; ///< Data register 2 __io uint32 DR3; ///< Data register 3 @@ -61,8 +61,8 @@ typedef struct bkp_reg_map { __io uint32 CR; ///< Control register __io uint32 CSR; ///< Control and status register #ifdef STM32_HIGH_DENSITY - const uint32 RESERVED2; - const uint32 RESERVED3; + const uint32 RESERVED2; ///< Reserved + const uint32 RESERVED3; ///< Reserved __io uint32 DR11; ///< Data register 11 __io uint32 DR12; ///< Data register 12 __io uint32 DR13; ///< Data register 13 diff --git a/libmaple/dma.h b/libmaple/dma.h index c763672..7c380d0 100644 --- a/libmaple/dma.h +++ b/libmaple/dma.h @@ -417,6 +417,8 @@ static inline uint8 dma_is_channel_enabled(dma_dev *dev, dma_channel channel) { * If you're attempting to figure out why a DMA interrupt fired; you * may find dma_get_irq_cause() more convenient. * + * @param dev DMA device + * @param channel Channel whose ISR bits to return. * @see dma_get_irq_cause(). */ static inline uint8 dma_get_isr_bits(dma_dev *dev, dma_channel channel) { @@ -430,6 +432,8 @@ static inline uint8 dma_get_isr_bits(dma_dev *dev, dma_channel channel) { * If you're attempting to clean up after yourself in a DMA interrupt, * you may find dma_get_irq_cause() more convenient. * + * @param dev DMA device + * @param channel Channel whose ISR bits to clear. * @see dma_get_irq_cause() */ static inline void dma_clear_isr_bits(dma_dev *dev, dma_channel channel) { diff --git a/libmaple/ring_buffer.h b/libmaple/ring_buffer.h index 101f010..ad6ad96 100644 --- a/libmaple/ring_buffer.h +++ b/libmaple/ring_buffer.h @@ -89,7 +89,7 @@ static inline uint16 rb_full_count(ring_buffer *rb) { /** * @brief Returns true if and only if the ring buffer is full. - * @brief rb Buffer to test. + * @param rb Buffer to test. */ static inline int rb_is_full(ring_buffer *rb) { return (rb->tail + 1 == rb->head) || @@ -139,8 +139,8 @@ static inline int16 rb_safe_remove(ring_buffer *rb) { /** * @brief Attempt to insert an element into a ring buffer. * - * @brief rb Buffer to insert into. - * @brief element Value to insert into rb. + * @param rb Buffer to insert into. + * @param element Value to insert into rb. * @sideeffect If rb is not full, appends element onto buffer. * @return If element was appended, then true; otherwise, false. */ static inline int rb_safe_insert(ring_buffer *rb, uint8 element) { diff --git a/libmaple/timer.h b/libmaple/timer.h index fa19cc9..befc026 100644 --- a/libmaple/timer.h +++ b/libmaple/timer.h @@ -628,8 +628,8 @@ static inline uint16 timer_get_count(timer_dev *dev) { /** * @brief Sets the counter value for the given timer. - * @param timer_num Timer whose counter to set - * @param value New counter value + * @param dev Timer whose counter to set + * @param value New counter value */ static inline void timer_set_count(timer_dev *dev, uint16 value) { (dev->regs).bas->CNT = value; @@ -804,8 +804,8 @@ static inline void timer_cc_disable(timer_dev *dev, uint8 channel) { /** * @brief Get a channel's capture/compare output polarity - * @brief dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. - * @brief channel Channel whose capture/compare output polarity to get. + * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. + * @param channel Channel whose capture/compare output polarity to get. * @return Polarity, either 0 or 1. * @see timer_cc_set_polarity() */ @@ -982,6 +982,7 @@ typedef enum timer_oc_mode_flags { * * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. * @param channel Channel to configure in output compare mode. + * @param mode Timer mode to set. * @param flags OR of timer_oc_mode_flags. * @see timer_oc_mode * @see timer_oc_mode_flags diff --git a/wirish/pwm.h b/wirish/pwm.h index a6385e9..4ce4bb4 100644 --- a/wirish/pwm.h +++ b/wirish/pwm.h @@ -43,6 +43,9 @@ * * User code is expected to determine and honor the maximum value * (based on the configured period). + * + * @param pin PWM output pin + * @param duty_cycle Duty cycle to set. */ void pwmWrite(uint8 pin, uint16 duty_cycle); diff --git a/wirish/wirish_time.h b/wirish/wirish_time.h index a0c0c82..a0b1c11 100644 --- a/wirish/wirish_time.h +++ b/wirish/wirish_time.h @@ -23,7 +23,7 @@ *****************************************************************************/ /** - * @file time.h + * @file wirish_time.h * @brief Timing and delay functions. */ diff --git a/wirish/wirish_types.h b/wirish/wirish_types.h index 475f470..39efae0 100644 --- a/wirish/wirish_types.h +++ b/wirish/wirish_types.h @@ -57,6 +57,9 @@ typedef struct stm32_pin_info { uint8 adc_channel; /**< Pin ADC channel, or ADCx if none. */ } stm32_pin_info; +/** + * Variable attribute, instructs the linker to place the marked + * variable in Flash instead of RAM. */ #define __FLASH__ __attr_flash #endif -- cgit v1.2.3 From 2ffc87ca9b47bd605e5630a33b36f83e5e8486da Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Tue, 12 Apr 2011 00:44:05 -0400 Subject: Changing usages of "volatile" to "__io". --- libmaple/i2c.h | 2 +- libmaple/ring_buffer.h | 6 ++++-- libmaple/systick.c | 2 +- libmaple/systick.h | 2 +- libmaple/util.h | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) (limited to 'libmaple/ring_buffer.h') diff --git a/libmaple/i2c.h b/libmaple/i2c.h index 21c17c1..a17e144 100644 --- a/libmaple/i2c.h +++ b/libmaple/i2c.h @@ -66,7 +66,7 @@ typedef struct i2c_dev { uint8 clk_line; uint8 ev_nvic_line; uint8 er_nvic_line; - volatile uint8 state; + __io uint8 state; uint16 msgs_left; i2c_msg *msg; } i2c_dev; diff --git a/libmaple/ring_buffer.h b/libmaple/ring_buffer.h index ad6ad96..04f6499 100644 --- a/libmaple/ring_buffer.h +++ b/libmaple/ring_buffer.h @@ -35,6 +35,8 @@ #ifndef _RING_BUFFER_H_ #define _RING_BUFFER_H_ +#include "libmaple_types.h" + #ifdef __cplusplus extern "C"{ #endif @@ -49,7 +51,7 @@ extern "C"{ * * One byte is left free to distinguish empty from full. */ typedef struct ring_buffer { - volatile uint8 *buf; /**< Buffer items are stored into */ + __io uint8 *buf; /**< Buffer items are stored into */ uint16 head; /**< Index of the next item to remove */ uint16 tail; /**< Index where the next item will get inserted */ uint16 size; /**< Buffer capacity minus one */ @@ -79,7 +81,7 @@ static inline void rb_init(ring_buffer *rb, uint16 size, uint8 *buf) { * @param rb Buffer whose elements to count. */ static inline uint16 rb_full_count(ring_buffer *rb) { - volatile ring_buffer *arb = rb; + __io ring_buffer *arb = rb; int32 size = arb->tail - arb->head; if (arb->tail < arb->head) { size += arb->size + 1; diff --git a/libmaple/systick.c b/libmaple/systick.c index c04f4f3..103893e 100644 --- a/libmaple/systick.c +++ b/libmaple/systick.c @@ -28,7 +28,7 @@ #include "systick.h" -volatile uint32 systick_timer_millis; +__io uint32 systick_timer_millis; /** * @brief Initialize and enable SysTick. diff --git a/libmaple/systick.h b/libmaple/systick.h index 35b4cb9..4654c5f 100644 --- a/libmaple/systick.h +++ b/libmaple/systick.h @@ -73,7 +73,7 @@ typedef struct systick_reg_map { #define SYSTICK_CVR_TENMS 0xFFFFFF /** System elapsed time, in milliseconds */ -extern volatile uint32 systick_timer_millis; +extern __io uint32 systick_timer_millis; void systick_init(uint32 reload_val); void systick_disable(); diff --git a/libmaple/util.h b/libmaple/util.h index aff70e1..4c47764 100644 --- a/libmaple/util.h +++ b/libmaple/util.h @@ -50,8 +50,8 @@ extern "C"{ * Register reads and writes */ -#define __read(reg) (*(volatile uint32*)(reg)) -#define __write(reg, value) (*(volatile uint32*)(reg) = (value)) +#define __read(reg) (*(__io uint32*)(reg)) +#define __write(reg, value) (*(__io uint32*)(reg) = (value)) /* * Failure routines -- cgit v1.2.3 From 298661aa1c189400f27328fa77d5b3a10f1ba3ef Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Tue, 12 Apr 2011 15:50:18 -0400 Subject: Reverting some "volatile" -> "__io" changes. See https://github.com/leaflabs/libmaple/commit/c57d760676b97a0fc9cb51db99c8400bae2cb3b7#commitcomment-338822 --- libmaple/i2c.h | 2 +- libmaple/ring_buffer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'libmaple/ring_buffer.h') diff --git a/libmaple/i2c.h b/libmaple/i2c.h index 07ee260..394fd57 100644 --- a/libmaple/i2c.h +++ b/libmaple/i2c.h @@ -66,7 +66,7 @@ typedef struct i2c_dev { uint8 clk_line; uint8 ev_nvic_line; uint8 er_nvic_line; - __io uint8 state; + volatile uint8 state; uint16 msgs_left; i2c_msg *msg; } i2c_dev; diff --git a/libmaple/ring_buffer.h b/libmaple/ring_buffer.h index 04f6499..2536617 100644 --- a/libmaple/ring_buffer.h +++ b/libmaple/ring_buffer.h @@ -51,7 +51,7 @@ extern "C"{ * * One byte is left free to distinguish empty from full. */ typedef struct ring_buffer { - __io uint8 *buf; /**< Buffer items are stored into */ + volatile uint8 *buf; /**< Buffer items are stored into */ uint16 head; /**< Index of the next item to remove */ uint16 tail; /**< Index where the next item will get inserted */ uint16 size; /**< Buffer capacity minus one */ -- cgit v1.2.3