diff --git a/ChangeLog b/ChangeLog index e294002..5ead08d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2018-10-01 NIIBE Yutaka + + * 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 * VERSION: 1.10. diff --git a/NEWS b/NEWS index fc37fa6..38c3a34 100644 --- a/NEWS +++ b/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 diff --git a/chopstx.c b/chopstx.c index ce57312..997e52f 100644 --- a/chopstx.c +++ b/chopstx.c @@ -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 (); diff --git a/contrib/ackbtn-stm32f103.c b/contrib/ackbtn-stm32f103.c index 3c392ff..dc28bb6 100644 --- a/contrib/ackbtn-stm32f103.c +++ b/contrib/ackbtn-stm32f103.c @@ -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); }