GPT driver tested on STM32L.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3341 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
gdisirio 2011-09-18 18:23:50 +00:00
parent 373735d529
commit 07f868d379
4 changed files with 12 additions and 12 deletions

View File

@ -135,13 +135,7 @@ typedef struct {
volatile uint32_t PUPDR;
volatile uint32_t IDR;
volatile uint32_t ODR;
volatile union {
uint32_t W;
struct {
uint16_t set;
uint16_t clear;
} H;
} BSRR;
volatile uint32_t BSRR;
volatile uint32_t LCKR;
volatile uint32_t AFRL;
volatile uint32_t AFRH;
@ -375,7 +369,7 @@ typedef GPIO_TypeDef * ioportid_t;
*
* @notapi
*/
#define pal_lld_setport(port, bits) ((port)->BSRR.H.set = (uint16_t)(bits))
#define pal_lld_setport(port, bits) ((port)->BSRR = (uint32_t)(bits))
/**
* @brief Clears a bits mask on a I/O port.
@ -392,7 +386,7 @@ typedef GPIO_TypeDef * ioportid_t;
*
* @notapi
*/
#define pal_lld_clearport(port, bits) ((port)->BSRR.H.clear = (uint16_t)(bits))
#define pal_lld_clearport(port, bits) ((port)->BSRR = (uint32_t)(bits) << 16)
/**
* @brief Writes a group of bits.
@ -413,8 +407,8 @@ typedef GPIO_TypeDef * ioportid_t;
* @notapi
*/
#define pal_lld_writegroup(port, mask, offset, bits) \
((port)->BSRR.W = ((~(bits) & (mask)) << (16 + (offset))) | \
(((bits) & (mask)) << (offset)))
((port)->BSRR = ((~(bits) & (mask)) << (16 + (offset))) | \
(((bits) & (mask)) << (offset)))
/**
* @brief Pads group mode setup.

View File

@ -86,8 +86,10 @@ int main(void) {
* five seconds.
*/
while (TRUE) {
gptStopTimer(&GPTD1);
gptStartContinuous(&GPTD1, 5000);
chThdSleepMilliseconds(5000);
gptStopTimer(&GPTD1);
gptStartContinuous(&GPTD1, 2500);
chThdSleepMilliseconds(5000);
}

View File

@ -5,7 +5,7 @@
# Compiler options here.
ifeq ($(USE_OPT),)
USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
endif
# C++ specific options here (added to USE_OPT).

View File

@ -86,8 +86,12 @@ int main(void) {
* five seconds.
*/
while (TRUE) {
palSetPad(GPIOB, GPIOB_LED3);
gptStopTimer(&GPTD2);
gptStartContinuous(&GPTD2, 5000);
chThdSleepMilliseconds(5000);
palClearPad(GPIOB, GPIOB_LED3);
gptStopTimer(&GPTD2);
gptStartContinuous(&GPTD2, 2500);
chThdSleepMilliseconds(5000);
}