Fix ackbtn clearing the edge detector.
This commit is contained in:
15
ChangeLog
15
ChangeLog
@@ -1,3 +1,18 @@
|
||||
2018-10-01 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* contrib/ackbtn-stm32f103.c (PINCFG_EDGE): New.
|
||||
(ackbtn_init): Use PINCFG_EDGE bit.
|
||||
(ackbtn_enable): Configure the edge detector here.
|
||||
(ackbtn_disable): Disable the edge detector.
|
||||
|
||||
* chopstx.c (chopstx_poll): Don't clear ->ready here.
|
||||
(chx_cond_hook): Set ->ready = 0 when condition does
|
||||
not meet.
|
||||
(chopstx_claim_irq): Make sure clearing the interrupt.
|
||||
(chx_intr_hook): Add the case when ->ready == 1.
|
||||
(chopstx_intr_done): Set ->ready = 0.
|
||||
(chx_join_hook): Set ->ready = 0 when it is still alive.
|
||||
|
||||
2018-09-29 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* VERSION: 1.10.
|
||||
|
||||
16
NEWS
16
NEWS
@@ -1,6 +1,22 @@
|
||||
NEWS - Noteworthy changes
|
||||
|
||||
|
||||
* Major changes in Chopstx 1.11
|
||||
|
||||
Released 2018-10-01
|
||||
|
||||
** Support calling chopstx_poll with intr->ready==1.
|
||||
In version <= 1.10, it assumed that all events should be handled after
|
||||
chopstx_poll, before calling chopstx_poll again. With having
|
||||
chopstx_intr_done, it's OK now that chopstx_poll can be called again
|
||||
not examining/handling all poll descriptors, but only parts of them.
|
||||
|
||||
** Acknowledge button change.
|
||||
In 1.10, the action was "memorized" by the edge detector. Now, edge
|
||||
detector is disabled by ackbtn_disable, and it is enabled by
|
||||
ackbtn_enable. So, the status is cleared correctly.
|
||||
|
||||
|
||||
* Major changes in Chopstx 1.10
|
||||
|
||||
Released 2018-09-29
|
||||
|
||||
@@ -999,6 +999,7 @@ chopstx_claim_irq (chopstx_intr_t *intr, uint8_t irq_num)
|
||||
chx_cpu_sched_lock ();
|
||||
chx_spin_lock (&q_intr.lock);
|
||||
chx_disable_intr (irq_num);
|
||||
chx_clr_intr (irq_num);
|
||||
chx_set_intr_prio (irq_num);
|
||||
chx_spin_unlock (&q_intr.lock);
|
||||
chx_cpu_sched_unlock ();
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include "sys.h"
|
||||
|
||||
static uint32_t pin_config;
|
||||
#define PINCFG_EDGE 0x80000000
|
||||
#define PINCFG_EDGE_RISING PINCFG_EDGE
|
||||
|
||||
void
|
||||
ackbtn_init (chopstx_intr_t *intr)
|
||||
@@ -42,7 +44,6 @@ ackbtn_init (chopstx_intr_t *intr)
|
||||
uint8_t irq_num;
|
||||
uint32_t afio_exticr_index;
|
||||
uint32_t afio_exticr_extiX_pY;
|
||||
int rising_edge;
|
||||
|
||||
switch (SYS_BOARD_ID)
|
||||
{
|
||||
@@ -53,36 +54,43 @@ ackbtn_init (chopstx_intr_t *intr)
|
||||
afio_exticr_extiX_pY = AFIO_EXTICR1_EXTI3_PA;
|
||||
irq_num = EXTI3_IRQ;
|
||||
pin_config = 0x0008; /* EXTI_PR_PR3 == EXTI_IMR_MR3 == EXTI_RTSR_TR3 */
|
||||
rising_edge = 1;
|
||||
pin_config |= PINCFG_EDGE_RISING;
|
||||
break;
|
||||
}
|
||||
|
||||
chopstx_claim_irq (intr, irq_num);
|
||||
|
||||
/* Configure EXTI line */
|
||||
if (afio_exticr_extiX_pY)
|
||||
AFIO->EXTICR[afio_exticr_index] |= afio_exticr_extiX_pY;
|
||||
|
||||
/* Interrupt is masked, now */
|
||||
EXTI->IMR &= ~pin_config;
|
||||
EXTI->IMR &= ~(pin_config & ~PINCFG_EDGE);
|
||||
|
||||
/* Configure which edge is detected */
|
||||
if (rising_edge)
|
||||
EXTI->RTSR |= pin_config;
|
||||
else
|
||||
EXTI->FTSR |= pin_config;
|
||||
chopstx_claim_irq (intr, irq_num);
|
||||
}
|
||||
|
||||
void
|
||||
ackbtn_enable (void)
|
||||
{
|
||||
EXTI->PR |= pin_config; /* Clear pending interrupt */
|
||||
EXTI->IMR |= pin_config; /* Enable interrupt clearing the mask */
|
||||
/* Clear pending interrupt */
|
||||
EXTI->PR |= (pin_config & ~PINCFG_EDGE);
|
||||
/* Enable interrupt, clearing the mask */
|
||||
EXTI->IMR |= (pin_config & ~PINCFG_EDGE);
|
||||
|
||||
/* Configure which edge is detected */
|
||||
if ((pin_config & PINCFG_EDGE))
|
||||
EXTI->RTSR |= (pin_config & ~PINCFG_EDGE);
|
||||
else
|
||||
EXTI->FTSR |= (pin_config & ~PINCFG_EDGE);
|
||||
}
|
||||
|
||||
void
|
||||
ackbtn_disable (void)
|
||||
{
|
||||
EXTI->IMR &= ~pin_config; /* Disable interrupt having the mask */
|
||||
EXTI->PR |= pin_config; /* Clear pending interrupt */
|
||||
/* Disable interrupt having the mask */
|
||||
EXTI->IMR &= ~(pin_config & ~PINCFG_EDGE);
|
||||
/* Clear pending interrupt */
|
||||
|
||||
/* Disable edge detection */
|
||||
EXTI->RTSR &= ~(pin_config & ~PINCFG_EDGE);
|
||||
EXTI->FTSR &= ~(pin_config & ~PINCFG_EDGE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user