aboutsummaryrefslogtreecommitdiff
path: root/example-fs-bb48
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2016-06-29 17:05:33 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2016-06-29 17:05:33 +0900
commitc71a24ddcb22b8ba5d1fb45d1393838d1110b1b5 (patch)
treed4795b8fbcdb30a935ae7a71a49e41c2ca38d027 /example-fs-bb48
parent663cbabe7c2de647d7e8335f18474b108676cbb0 (diff)
MKL27Z touch
Diffstat (limited to 'example-fs-bb48')
-rw-r--r--example-fs-bb48/touch.c61
1 files changed, 25 insertions, 36 deletions
diff --git a/example-fs-bb48/touch.c b/example-fs-bb48/touch.c
index ec9a0bf..033da62 100644
--- a/example-fs-bb48/touch.c
+++ b/example-fs-bb48/touch.c
@@ -24,42 +24,6 @@ static struct TPM *const TPM1 = (struct TPM *const)0x40039000;
static chopstx_intr_t tpm1_intr;
#define INTR_REQ_TPM1 18
-void
-touch_init (void)
-{
- chopstx_claim_irq (&tpm1_intr, INTR_REQ_TPM1);
-
- PORTB->PCR1 = (1<<3) /* TPM1_CH1 */
- | (0<<6) /* DriveStrengthEnable=0 */
- | (0<<4) /* PassiveFilterEnable=0 */
- | (1<<2) /* SlewRateEnable = slow */
- | (0<<1) /* pull enable = 0 */
- | (0<<0) /* puddselect= 0 */
- ;
-
- /* 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;
- 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;
-
- /* Wait overflow. */
- chopstx_intr_wait (&tpm1_intr);
-
- /* Clear overflow. */
- TPM1->SC |= 0x80;
-}
-
uint16_t
touch_get (void)
{
@@ -87,3 +51,28 @@ touch_get (void)
return TPM1->C1V;
}
+
+
+void
+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;
+ 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 ();
+}