static void udi_cdc_serial_state_msg_sent(udd_ep_status_t status, iram_size_t n, udd_ep_id_t ep) { uint8_t port; UNUSED(n); UNUSED(status); switch (ep) { #define UDI_CDC_GET_PORT_FROM_COMM_EP(iface, unused) \ case UDI_CDC_COMM_EP_##iface: \ port = iface; \ break; MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_GET_PORT_FROM_COMM_EP, ~) #undef UDI_CDC_GET_PORT_FROM_COMM_EP default: port = 0; break; } udi_cdc_serial_state_msg_ongoing[port] = false; // For the irregular signals like break, the incoming ring signal, // or the overrun error state, this will reset their values to zero // and again will not send another notification until their state changes. udi_cdc_state[port] &= ~(CDC_SERIAL_STATE_BREAK | CDC_SERIAL_STATE_RING | CDC_SERIAL_STATE_FRAMING | CDC_SERIAL_STATE_PARITY | CDC_SERIAL_STATE_OVERRUN); uid_cdc_state_msg[port].value &= ~(CDC_SERIAL_STATE_BREAK | CDC_SERIAL_STATE_RING | CDC_SERIAL_STATE_FRAMING | CDC_SERIAL_STATE_PARITY | CDC_SERIAL_STATE_OVERRUN); // Send it if possible and state changed udi_cdc_ctrl_state_notify(port, ep); }
static void udi_cdc_ctrl_state_change(uint8_t port, bool b_set, le16_t bit_mask) { irqflags_t flags; udd_ep_id_t ep_comm; #if UDI_CDC_PORT_NB == 1 // To optimize code port = 0; #endif // Update state flags = cpu_irq_save(); // Protect udi_cdc_state if (b_set) { udi_cdc_state[port] |= bit_mask; } else { udi_cdc_state[port] &= ~(unsigned)bit_mask; } cpu_irq_restore(flags); // Send it if possible and state changed switch (port) { #define UDI_CDC_PORT_TO_COMM_EP(index, unused) \ case index: \ ep_comm = UDI_CDC_COMM_EP_##index; \ break; MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_PORT_TO_COMM_EP, ~) #undef UDI_CDC_PORT_TO_COMM_EP default: ep_comm = UDI_CDC_COMM_EP_0; break; } udi_cdc_ctrl_state_notify(port, ep_comm); }
static void udi_cdc_ctrl_state_change(bool b_set, le16_t bit_mask) { irqflags_t flags; // Update state flags = cpu_irq_save(); // Protect udi_cdc_state if (b_set) { udi_cdc_state |= bit_mask; } else { udi_cdc_state &= ~bit_mask; } cpu_irq_restore(flags); // Send it if possible and state changed udi_cdc_ctrl_state_notify(); }
void udi_cdc_serial_state_msg_sent(udd_ep_status_t status, iram_size_t n) { udi_cdc_serial_state_msg_ongoing = false; // For the irregular signals like break, the incoming ring signal, // or the overrun error state, this will reset their values to zero // and again will not send another notification until their state changes. udi_cdc_state &= ~(CDC_SERIAL_STATE_BREAK | CDC_SERIAL_STATE_RING | CDC_SERIAL_STATE_FRAMING | CDC_SERIAL_STATE_PARITY | CDC_SERIAL_STATE_OVERRUN); uid_cdc_state_msg.value &= ~(CDC_SERIAL_STATE_BREAK | CDC_SERIAL_STATE_RING | CDC_SERIAL_STATE_FRAMING | CDC_SERIAL_STATE_PARITY | CDC_SERIAL_STATE_OVERRUN); // Send it if possible and state changed udi_cdc_ctrl_state_notify(); }