version 0.6

This commit is contained in:
NIIBE Yutaka
2011-01-14 15:47:15 +09:00
parent c8bcb69988
commit f7e26ae952
9 changed files with 158 additions and 10 deletions

View File

@@ -14,6 +14,36 @@ void
hwinit1 (void)
{
hwinit1_common ();
#if defined(PINPAD_SUPPORT)
/* EXTI5 <= PB5 */
AFIO->EXTICR[1] = AFIO_EXTICR2_EXTI5_PB;
EXTI->IMR = 0;
EXTI->FTSR = EXTI_FTSR_TR5;
NVICEnableVector(EXTI9_5_IRQn,
CORTEX_PRIORITY_MASK(CORTEX_MINIMUM_PRIORITY));
/* TIM3 */
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
RCC->APB1RSTR = RCC_APB1RSTR_TIM3RST;
RCC->APB1RSTR = 0;
NVICEnableVector(TIM3_IRQn,
CORTEX_PRIORITY_MASK(CORTEX_MINIMUM_PRIORITY));
TIM3->CR1 = TIM_CR1_URS | TIM_CR1_ARPE; /* Don't enable TIM3 for now */
TIM3->CR2 = TIM_CR2_TI1S;
TIM3->SMCR = TIM_SMCR_TS_0 | TIM_SMCR_TS_2 | TIM_SMCR_SMS_2;
TIM3->DIER = 0; /* Disable interrupt for now */
TIM3->CCMR1 = TIM_CCMR1_CC1S_0 | TIM_CCMR1_IC1F_0 | TIM_CCMR1_IC1F_3
| TIM_CCMR1_CC2S_1 | TIM_CCMR1_IC2F_0 | TIM_CCMR1_IC2F_3;
TIM3->CCMR2 = 0;
TIM3->CCER = TIM_CCER_CC1E | TIM_CCER_CC2E | TIM_CCER_CC2P;
TIM3->PSC = 72 - 1; /* 1 MHz */
TIM3->ARR = 18000; /* 18 ms */
/* Generate UEV to upload PSC and ARR */
TIM3->EGR = TIM_EGR_UG;
#endif
/* Remap (PB4, PB5) -> (TIM3_CH1, TIM3_CH2) */
AFIO->MAPR |= AFIO_MAPR_TIM3_REMAP_PARTIALREMAP;
}
void
@@ -31,3 +61,43 @@ set_led (int value)
else
palClearPad (IOPORT1, GPIOA_LED);
}
#if defined(PINPAD_SUPPORT)
void
cir_ext_disable (void)
{
EXTI->PR = EXTI_PR_PR5;
EXTI->IMR &= ~EXTI_IMR_MR5;
}
void
cir_ext_enable (void)
{
EXTI->IMR |= EXTI_IMR_MR5;
}
extern void cir_ext_interrupt (void);
extern void cir_timer_interrupt (void);
CH_IRQ_HANDLER (EXTI9_5_IRQHandler)
{
CH_IRQ_PROLOGUE ();
chSysLockFromIsr ();
cir_ext_interrupt ();
chSysUnlockFromIsr ();
CH_IRQ_EPILOGUE ();
}
CH_IRQ_HANDLER (TIM3_IRQHandler)
{
CH_IRQ_PROLOGUE();
chSysLockFromIsr();
cir_timer_interrupt ();
chSysUnlockFromIsr();
CH_IRQ_EPILOGUE();
}
#endif

View File

@@ -27,6 +27,7 @@
#ifndef _BOARD_H_
#define _BOARD_H_
#include "config.h"
/*
* Setup for the ST-Link part of STM8S-Discovery board.
*/
@@ -90,6 +91,16 @@
#define VAL_GPIOACRH 0x88888883 /* PA15...PA8 */
#define VAL_GPIOAODR 0xFFFFFFFF
#if defined(PINPAD_SUPPORT)
/*
* Port B setup.
* Everything input with pull-up except:
* PB0 - (TIM3_CH3) input with pull-down
*/
#define VAL_GPIOBCRL 0x88888888 /* PB7...PB0 */
#define VAL_GPIOBCRH 0x88888888 /* PB15...PB8 */
#define VAL_GPIOBODR 0xFFFFFFFE
#else
/*
* Port B setup.
* Everything input with pull-up except:
@@ -97,6 +108,7 @@
#define VAL_GPIOBCRL 0x88888888 /* PB7...PB0 */
#define VAL_GPIOBCRH 0x88888888 /* PB15...PB8 */
#define VAL_GPIOBODR 0xFFFFFFFF
#endif
/*
* Port C setup.