Update for MKL27Z
This commit is contained in:
@@ -19,7 +19,7 @@ struct TPM {
|
||||
volatile uint32_t CONF;
|
||||
};
|
||||
|
||||
static struct TPM *const TPM1 = (struct TPM *const)0x40039000;
|
||||
static struct TPM *const TPM1 = (struct TPM *)0x40039000;
|
||||
|
||||
static chopstx_intr_t tpm1_intr;
|
||||
#define INTR_REQ_TPM1 18
|
||||
@@ -36,8 +36,14 @@ touch_get (void)
|
||||
| (0<<0) /* puddselect= 0 */
|
||||
;
|
||||
|
||||
/*
|
||||
* Start the timer's counter.
|
||||
* TOF clear, TOIE=1, CPWMS=0, CMOD=1, PS=011.
|
||||
*/
|
||||
TPM1->SC = 0xcb;
|
||||
|
||||
/* Let the register to pull it up. */
|
||||
PORTB->PCR1 = (1<<3) /* TPM1_CH1 */
|
||||
PORTB->PCR1 = (3<<8) /* TPM1_CH1 */
|
||||
| (0<<6) /* DriveStrengthEnable=0 */
|
||||
| (0<<4) /* PassiveFilterEnable=0 */
|
||||
| (1<<2) /* SlewRateEnable = slow */
|
||||
@@ -46,8 +52,10 @@ touch_get (void)
|
||||
;
|
||||
|
||||
chopstx_intr_wait (&tpm1_intr);
|
||||
/* Clear overflow. */
|
||||
TPM1->SC |= 0x80;
|
||||
/* Clear overflow and CH1 capture. */
|
||||
TPM1->STATUS = 0x102;
|
||||
/* Stop the counter. */
|
||||
TPM1->SC = 0;
|
||||
|
||||
return TPM1->C1V;
|
||||
}
|
||||
@@ -58,21 +66,13 @@ touch_init (void)
|
||||
{
|
||||
chopstx_claim_irq (&tpm1_intr, INTR_REQ_TPM1);
|
||||
|
||||
/* TOF clear, TOIE=1, CPWMS=0, CMOD=1, PS=000. */
|
||||
TPM1->SC = 0xc4;
|
||||
|
||||
/* Input capture mode: MSB = 0, MSA = 0 */
|
||||
/* Rising edge: ELSB=0 ELSA=1 */
|
||||
TPM1->C1SC = 0x82;
|
||||
/* Rising edge: ELSB=0 ELSA=1 */
|
||||
TPM1->C1SC = 0x84;
|
||||
TPM1->POL=0;
|
||||
|
||||
/* Triggered by TPM1_CH1. */
|
||||
/* channel 1: TRGSEL=0010 */
|
||||
/* external: TRGSRC=0 */
|
||||
/* active low:TRGPOL=1 */
|
||||
/* stop on overflow: CSOO=1 */
|
||||
/* start on trigger: CSOT=1 */
|
||||
TPM1->CONF = 0x02c30000;
|
||||
|
||||
touch_get ();
|
||||
/* No trigger. */
|
||||
/* Stop on overflow: CSOO=1 */
|
||||
/* Run the timer in the debug mode */
|
||||
TPM1->CONF = 0x000200c0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user