- /* Wait for some space in the fifo */
- while (!ao_radio_abort && (fifo_space = ao_radio_tx_fifo_space()) == 0) {
-#if CC1200_APRS_TRACE
- printf("APRS space %d cnt %d\n", fifo_space, cnt); flush();
-#endif
- ao_radio_wake = 0;
- ao_radio_wait_isr(AO_MS_TO_TICKS(1000));
- }
- if (ao_radio_abort)
- break;
- if (this_len > fifo_space)
- this_len = fifo_space;
-
- cnt -= this_len;
-
- if (done) {
- if (cnt)
- ao_radio_set_mode(AO_RADIO_MODE_APRS_LAST_BUF);
- else
- ao_radio_set_mode(AO_RADIO_MODE_APRS_FINISH);
- } else
- ao_radio_set_mode(AO_RADIO_MODE_APRS_BUF);
-
- ao_exti_enable(AO_CC1200_INT_PORT, AO_CC1200_INT_PIN);
-
- ao_radio_fifo_write(b, this_len);
- b += this_len;
-#if CC1200_APRS_TRACE
- printf("APRS write fifo %d space now %d\n", this_len, ao_radio_tx_fifo_space());
-#endif
- if (!started) {
-#if CC1200_APRS_TRACE
- printf("APRS start\n");
-#endif
- ao_radio_strobe(CC1200_STX);
-#if CC1200_APRS_TRACE
- { int t;
- for (t = 0; t < 20; t++) {
- uint8_t status = ao_radio_status();
- uint8_t space = ao_radio_tx_fifo_space();
- printf ("status: %02x fifo %d\n", status, space);
- if ((status >> 4) == 2)
- break;
- ao_delay(AO_MS_TO_TICKS(0));
- }
- }
-#endif
- started = 1;
- }
+ /* Wait for some space in the fifo */
+ ao_arch_block_interrupts();
+ while (started && ao_radio_int_pin() != 0 && !ao_radio_abort) {
+ ao_radio_wake = 0;
+ _ao_radio_wait_isr(AO_MS_TO_TICKS(1000));