Fix examples.

This commit is contained in:
NIIBE Yutaka
2018-09-26 10:47:42 +09:00
parent d4f4f80ad9
commit 43bbdb44dc
12 changed files with 49 additions and 6 deletions

View File

@@ -1,3 +1,17 @@
2018-09-26 NIIBE Yutaka <gniibe@fsij.org>
Fix for chopstx_intr_done. No spurious interrupts.
* contrib/adc-mkl27z.c (adc_wait_completion): Fix.
* contrib/adc-stm32f103.c (adc_wait_completion): Likewise.
* contrib/usart-stm32f103.c (usart_main): Likewise.
* example-cdc-gnu-linux/usb-cdc.c (tty_main): Likewise.
* example-cdc/usb-cdc.c (tty_main): Likewise.
* example-fraucheky/main.c (usb_main): Likewise.
* example-fs-bb48/touch.c (touch_get): Likewise.
* example-fs-bb48/usb-cdc.c (tty_main): Likewise.
* example-primer2/primer2-ts.c (adc3_conversion): Likewise.
* example-usb-serial/usb-cdc.c (cdc_main): Likewise.
2018-09-26 NIIBE Yutaka <gniibe@fsij.org>
* chopstx.h (chopstx_intr_done): New function.

12
NEWS
View File

@@ -1,6 +1,18 @@
NEWS - Noteworthy changes
* Major changes in Chopstx 1.10
Released 2018-09-XX
** Function chopstx_intr_wait is not deprecated, now.
Once, it was said that it's deprecated, but it's active again.
** API change: chopstx_poll, chopstx_intr_wait, chopstx_intr_done
To avoid spurious interrupt, we introduce new function
chopstx_intr_done, which should be called after interrupt handling.
* Major changes in Chopstx 1.9
Released 2018-05-09

View File

@@ -295,19 +295,20 @@ adc_stop (void)
int
adc_wait_completion (void)
{
struct chx_poll_head *pd_array[1] = { (struct chx_poll_head *)&adc_intr };
int i;
while (1)
{
/* Wait DMA completion */
chopstx_poll (NULL, 1, pd_array);
chopstx_intr_wait (&adc_intr);
DMA0->DSR_BCR = (1 << 24);
DMA1->DSR_BCR = (1 << 24);
adc_stop_conversion ();
chopstx_intr_done (&adc_intr);
for (i = 0; i < adc.count; i++)
*adc.p++ = (uint8_t)adc.buf[i];

View File

@@ -316,11 +316,10 @@ int
adc_wait_completion (void)
{
uint32_t flags;
struct chx_poll_head *pd_array[1] = { (struct chx_poll_head *)&adc_intr };
while (1)
{
chopstx_poll (NULL, 1, pd_array);
chopstx_intr_wait (&adc_intr);
flags = DMA1->ISR & STM32_DMA_ISR_MASK; /* Channel 1 interrupt cause. */
/*
* Clear interrupt cause of channel 1.
@@ -329,6 +328,7 @@ adc_wait_completion (void)
* and TEIF.
*/
DMA1->IFCR = (flags & ~1);
chopstx_intr_done (&adc_intr);
if ((flags & STM32_DMA_ISR_TEIF) != 0) /* DMA errors */
{

View File

@@ -541,10 +541,16 @@ usart_main (void *arg)
chopstx_poll (NULL, n, usart_poll);
if (usart2_intr.ready)
{
usart2_tx_ready = handle_intr (USART2, &usart2_rb_h2a, &usart2_stat);
chopstx_intr_done (&usart2_intr);
}
if (usart3_intr.ready)
{
usart3_tx_ready = handle_intr (USART3, &usart3_rb_h2a, &usart3_stat);
chopstx_intr_done (&usart3_intr);
}
if (usart2_tx_ready && usart2_app_write_event.ready)
usart2_tx_ready = handle_tx_ready (USART2,

View File

@@ -708,6 +708,7 @@ tty_main (void *arg)
*
*/
e = usb_lld_event_handler (&dev);
chopstx_intr_done (&usb_intr);
ep_num = USB_EVENT_ENDP (e);
if (ep_num != 0)

View File

@@ -719,6 +719,7 @@ tty_main (void *arg)
*
*/
e = usb_lld_event_handler (&dev);
chopstx_intr_done (&usb_intr);
ep_num = USB_EVENT_ENDP (e);
if (ep_num != 0)

View File

@@ -185,6 +185,7 @@ usb_main (void *arg)
event_handle:
e = usb_lld_event_handler (&dev);
chopstx_intr_done (&interrupt);
ep_num = USB_EVENT_ENDP (e);
if (ep_num != 0)

View File

@@ -74,6 +74,7 @@ touch_get (void)
TPM1->SC = 0;
TPM1->CNT = 0xffff; /* Writing causes reset of the counter. */
chopstx_intr_done (&tpm1_intr);
return v;
}

View File

@@ -708,6 +708,7 @@ tty_main (void *arg)
*
*/
e = usb_lld_event_handler (&dev);
chopstx_intr_done (&usb_intr);
ep_num = USB_EVENT_ENDP (e);
if (ep_num != 0)

View File

@@ -107,6 +107,10 @@ void adc3_conversion (uint32_t *result)
/* Stop conversion. */
ADC3->CR2 &= ~ADC_CR2_JSWSTART;
#if USE_ADC3_INTR
chopstx_intr_done (&adc3_intr);
#endif
return;
}

View File

@@ -770,6 +770,7 @@ cdc_main (void *arg)
*
*/
e = usb_lld_event_handler (&dev);
chopstx_intr_done (&usb_intr);
ep_num = USB_EVENT_ENDP (e);
if (ep_num != 0)