STM8L Demo and PAL driver working now.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2357 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
gdisirio 2010-11-13 09:41:55 +00:00
parent be60d348aa
commit 11c89928ea
4 changed files with 22 additions and 13 deletions

View File

@ -39,13 +39,13 @@ void hwinit(void) {
/* /*
* TIM2 initialization as system tick. * TIM2 initialization as system tick.
*/ */
CLK->PCKENR1 |= 32; /* PCKEN15, TIM2 clock source.*/ CLK->PCKENR1 |= CLK_PCKENR1_TIM2;
TIM2->PSCR = 4; /* Prescaler divide by 2^4=16.*/ TIM2->PSCR = 4; /* Prescaler divide by 2^4=16.*/
TIM2->ARRH = (uint8_t)(TIM2_ARR >> 8); TIM2->ARRH = (uint8_t)(TIM2_ARR >> 8);
TIM2->ARRL = (uint8_t)(TIM2_ARR); TIM2->ARRL = (uint8_t)(TIM2_ARR);
TIM2->CNTRH = 0; TIM2->CNTRH = 0;
TIM2->CNTRL = 0; TIM2->CNTRL = 0;
TIM2->SR1 = 0; TIM2->SR1 = 0;
TIM2->IER = 1; /* UIE */ TIM2->IER = TIM_IER_UIE;
TIM2->CR1 = 1; /* CEN */ TIM2->CR1 = TIM_CR1_CEN;
} }

View File

@ -116,7 +116,7 @@
* Port C initial setup. * Port C initial setup.
*/ */
#define VAL_GPIOCODR 0 #define VAL_GPIOCODR 0
#define VAL_GPIOCDDR (1 < PC_LED4) #define VAL_GPIOCDDR (1 << PC_LED4)
#define VAL_GPIOCCR1 0xFF /* All pull-up/push-pull. */ #define VAL_GPIOCCR1 0xFF /* All pull-up/push-pull. */
#define VAL_GPIOCCR2 0 #define VAL_GPIOCCR2 0
@ -132,7 +132,7 @@
* Port E initial setup. * Port E initial setup.
*/ */
#define VAL_GPIOEODR 0 #define VAL_GPIOEODR 0
#define VAL_GPIOEDDR (1 < PE_LED3) #define VAL_GPIOEDDR (1 << PE_LED3)
#define VAL_GPIOECR1 0xFF /* All pull-up/push-pull. */ #define VAL_GPIOECR1 0xFF /* All pull-up/push-pull. */
#define VAL_GPIOECR2 0 #define VAL_GPIOECR2 0
@ -144,6 +144,19 @@
#define VAL_GPIOFCR1 0xFF /* All pull-up/push-pull. */ #define VAL_GPIOFCR1 0xFF /* All pull-up/push-pull. */
#define VAL_GPIOFCR2 0 #define VAL_GPIOFCR2 0
/*
* TIM2-update ISR segment code. This code is injected into the appropriate
* ISR by the HAL.
*/
#define _TIM2_UPDATE_ISR() { \
if (TIM2->SR1 & TIM_SR1_UIF) { \
chSysLockFromIsr(); \
chSysTimerHandlerI(); \
chSysUnlockFromIsr(); \
TIM2->SR1 = 0; \
} \
}
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -211,7 +211,7 @@ exception_vector_t const _vectab[] = {
{0x82, _unhandled_exception}, /* vector18 */ {0x82, _unhandled_exception}, /* vector18 */
#endif #endif
#if defined(_TIM2_OVERFLOW_ISR) || defined(_USART2_TRANSMIT_ISR) #if defined(_TIM2_UPDATE_ISR) || defined(_USART2_TRANSMIT_ISR)
{0x82, vector19}, {0x82, vector19},
#else #else
{0x82, _unhandled_exception}, /* vector19 */ {0x82, _unhandled_exception}, /* vector19 */

View File

@ -29,14 +29,14 @@ static msg_t Thread1(void *arg) {
(void)arg; (void)arg;
while (TRUE) { while (TRUE) {
palClearPad(GPIOC, PC_LED4);
chThdSleepMilliseconds(500);
palSetPad(GPIOC, PC_LED4); palSetPad(GPIOC, PC_LED4);
chThdSleepMilliseconds(500); chThdSleepMilliseconds(500);
palClearPad(GPIOE, PE_LED3); palClearPad(GPIOC, PC_LED4);
chThdSleepMilliseconds(500); chThdSleepMilliseconds(500);
palSetPad(GPIOE, PE_LED3); palSetPad(GPIOE, PE_LED3);
chThdSleepMilliseconds(500); chThdSleepMilliseconds(500);
palClearPad(GPIOE, PE_LED3);
chThdSleepMilliseconds(500);
} }
return 0; return 0;
} }
@ -51,10 +51,6 @@ void main(void) {
*/ */
hwinit(); hwinit();
palClearPad(GPIOC, PC_LED4);
palSetPad(GPIOE, PE_LED3);
while(1);
/* /*
* OS initialization. * OS initialization.
*/ */