mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/netdev: use netdev_trigger_event_isr function
This commit is contained in:
parent
67bc0e13af
commit
3ad574a822
@ -36,9 +36,7 @@ static netdev_t *_dev;
|
||||
|
||||
void _irq_handler(void)
|
||||
{
|
||||
if (_dev->event_callback) {
|
||||
_dev->event_callback(_dev, NETDEV_EVENT_ISR);
|
||||
}
|
||||
netdev_trigger_event_isr(_dev);
|
||||
}
|
||||
|
||||
static int _get(netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
|
@ -99,7 +99,7 @@ static esp_err_t IRAM_ATTR _eth_input_callback(void *buffer, uint16_t len, void
|
||||
memcpy(_esp_eth_dev.rx_buf, buffer, len);
|
||||
_esp_eth_dev.rx_len = len;
|
||||
_esp_eth_dev.event = SYSTEM_EVENT_ETH_RX_DONE;
|
||||
_esp_eth_dev.netdev.event_callback(&_esp_eth_dev.netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(&_esp_eth_dev.netdev);
|
||||
|
||||
mutex_unlock(&_esp_eth_dev.dev_lock);
|
||||
|
||||
@ -351,7 +351,7 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t *
|
||||
_esp_eth_dev.link_up = true;
|
||||
if (SYSTEM_EVENT_MAX) {
|
||||
_esp_eth_dev.event = SYSTEM_EVENT_ETH_CONNECTED;
|
||||
_esp_eth_dev.netdev.event_callback(&_esp_eth_dev.netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(&_esp_eth_dev.netdev);
|
||||
}
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_DISCONNECTED:
|
||||
@ -359,7 +359,7 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t *
|
||||
_esp_eth_dev.link_up = false;
|
||||
if (SYSTEM_EVENT_MAX) {
|
||||
_esp_eth_dev.event = SYSTEM_EVENT_ETH_DISCONNECTED;
|
||||
_esp_eth_dev.netdev.event_callback(&_esp_eth_dev.netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(&_esp_eth_dev.netdev);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -185,7 +185,7 @@ static void IRAM_ATTR esp_now_scan_peers_timer_cb(void* arg)
|
||||
|
||||
if (dev->netdev.event_callback) {
|
||||
dev->scan_event++;
|
||||
dev->netdev.event_callback((netdev_t*)dev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr((netdev_t*)dev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ esp_err_t _esp_wifi_rx_cb(void *buffer, uint16_t len, void *eb)
|
||||
|
||||
/* trigger netdev event to read the data */
|
||||
_esp_wifi_dev.event_recv++;
|
||||
_esp_wifi_dev.netdev.event_callback(&_esp_wifi_dev.netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(&_esp_wifi_dev.netdev);
|
||||
|
||||
/* reset IRQ nesting counter */
|
||||
irq_interrupt_nesting--;
|
||||
@ -434,7 +434,7 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t *
|
||||
|
||||
_esp_wifi_dev.connected = true;
|
||||
_esp_wifi_dev.event_conn++;
|
||||
_esp_wifi_dev.netdev.event_callback(&_esp_wifi_dev.netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(&_esp_wifi_dev.netdev);
|
||||
|
||||
break;
|
||||
|
||||
@ -455,7 +455,7 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t *
|
||||
|
||||
_esp_wifi_dev.connected = false;
|
||||
_esp_wifi_dev.event_disc++;
|
||||
_esp_wifi_dev.netdev.event_callback(&_esp_wifi_dev.netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(&_esp_wifi_dev.netdev);
|
||||
|
||||
/* call disconnect to reset internal state */
|
||||
result = esp_wifi_disconnect();
|
||||
|
@ -302,7 +302,7 @@ static void _tap_isr(int fd, void *arg) {
|
||||
netdev_t *netdev = (netdev_t *)arg;
|
||||
|
||||
if (netdev->event_callback) {
|
||||
netdev->event_callback(netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(netdev);
|
||||
}
|
||||
else {
|
||||
puts("netdev_tap: _isr: no event callback.");
|
||||
|
@ -112,7 +112,7 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
||||
/* simulate TX_STARTED interrupt */
|
||||
if (netdev->event_callback) {
|
||||
dev->last_event = NETDEV_EVENT_TX_STARTED;
|
||||
netdev->event_callback(netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(netdev);
|
||||
thread_yield();
|
||||
}
|
||||
res = writev(dev->sock_fd, v, n + 2);
|
||||
@ -123,7 +123,7 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
||||
/* simulate TX_COMPLETE interrupt */
|
||||
if (netdev->event_callback) {
|
||||
dev->last_event = NETDEV_EVENT_TX_COMPLETE;
|
||||
netdev->event_callback(netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(netdev);
|
||||
thread_yield();
|
||||
}
|
||||
|
||||
@ -283,7 +283,7 @@ static void _socket_isr(int fd, void *arg)
|
||||
socket_zep_t *dev = (socket_zep_t *)netdev;
|
||||
|
||||
dev->last_event = NETDEV_EVENT_RX_COMPLETE;
|
||||
netdev->event_callback(netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(netdev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -526,7 +526,7 @@ void isr_radio(void)
|
||||
DEBUG("[nrf802154] Unhandled state: %x\n", (uint8_t)NRF_RADIO->STATE);
|
||||
}
|
||||
if (_state) {
|
||||
nrf802154_dev.netdev.event_callback(&nrf802154_dev.netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(&nrf802154_dev.netdev);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -307,7 +307,7 @@ void isr_radio(void)
|
||||
}
|
||||
else {
|
||||
rx_lock = 0;
|
||||
nrfmin_dev.event_callback(&nrfmin_dev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(&nrfmin_dev);
|
||||
}
|
||||
}
|
||||
else if (state == STATE_TX) {
|
||||
|
@ -65,11 +65,7 @@ static netdev_t *at86rfmega_dev;
|
||||
#else
|
||||
static void _irq_handler(void *arg)
|
||||
{
|
||||
netdev_t *dev = (netdev_t *) arg;
|
||||
|
||||
if (dev->event_callback) {
|
||||
dev->event_callback(dev, NETDEV_EVENT_ISR);
|
||||
}
|
||||
netdev_trigger_event_isr(arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -762,7 +758,7 @@ ISR(TRX24_RX_END_vect, ISR_BLOCK)
|
||||
|
||||
((at86rf2xx_t *)at86rfmega_dev)->irq_status |= AT86RF2XX_IRQ_STATUS_MASK__RX_END;
|
||||
/* Call upper layer to process received data */
|
||||
at86rfmega_dev->event_callback(at86rfmega_dev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(at86rfmega_dev);
|
||||
|
||||
atmega_exit_isr();
|
||||
}
|
||||
@ -806,7 +802,7 @@ ISR(TRX24_TX_END_vect, ISR_BLOCK)
|
||||
dev->irq_status |= AT86RF2XX_IRQ_STATUS_MASK__TX_END;
|
||||
|
||||
/* Call upper layer to process if data was send successful */
|
||||
at86rfmega_dev->event_callback(at86rfmega_dev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(at86rfmega_dev);
|
||||
}
|
||||
|
||||
atmega_exit_isr();
|
||||
|
@ -89,7 +89,7 @@ void cc110x_on_gdo(void *_dev)
|
||||
mutex_unlock(&dev->isr_signal);
|
||||
}
|
||||
else {
|
||||
dev->netdev.event_callback(&dev->netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(&dev->netdev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,7 @@ static void _irq_handler(void *arg)
|
||||
{
|
||||
netdev_t *dev = (netdev_t *)arg;
|
||||
|
||||
if(dev->event_callback) {
|
||||
dev->event_callback(dev, NETDEV_EVENT_ISR);
|
||||
}
|
||||
netdev_trigger_event_isr(dev);
|
||||
}
|
||||
|
||||
static inline uint16_t to_u16(const void *buf)
|
||||
|
@ -71,7 +71,7 @@ static dose_signal_t state_transit_blocked(dose_t *ctx, dose_signal_t signal)
|
||||
* if this frame should be processed. By queuing NETDEV_EVENT_ISR,
|
||||
* the netif thread will call _isr at some time. */
|
||||
SETBIT(ctx->flags, DOSE_FLAG_RECV_BUF_DIRTY);
|
||||
ctx->netdev.event_callback((netdev_t *) ctx, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr((netdev_t *) ctx);
|
||||
}
|
||||
|
||||
if (ctx->sense_pin != GPIO_UNDEF) {
|
||||
|
@ -253,8 +253,7 @@ static void on_int(void *arg)
|
||||
/* disable global interrupt enable bit to avoid losing interrupts */
|
||||
cmd_bfc((enc28j60_t *)arg, REG_EIE, -1, EIE_INTIE);
|
||||
|
||||
netdev_t *netdev = (netdev_t *)arg;
|
||||
netdev->event_callback(arg, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(arg);
|
||||
}
|
||||
|
||||
static int nd_send(netdev_t *netdev, const iolist_t *iolist)
|
||||
|
@ -99,7 +99,7 @@ static void encx24j600_isr(void *arg)
|
||||
gpio_irq_disable(dev->int_pin);
|
||||
|
||||
/* call netdev hook */
|
||||
dev->netdev.event_callback((netdev_t*) dev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr((netdev_t*) dev);
|
||||
}
|
||||
|
||||
static void _isr(netdev_t *netdev)
|
||||
|
@ -123,7 +123,8 @@ static void _end_of_frame(ethos_t *dev)
|
||||
if (dev->framesize) {
|
||||
assert(dev->last_framesize == 0);
|
||||
dev->last_framesize = dev->framesize;
|
||||
dev->netdev.event_callback((netdev_t*) dev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr((netdev_t*) dev);
|
||||
|
||||
}
|
||||
break;
|
||||
case ETHOS_FRAME_TYPE_HELLO:
|
||||
|
@ -63,9 +63,7 @@ static void _irq_handler(void *arg)
|
||||
/* We use this counter to avoid filling the message queue with redundant ISR events */
|
||||
if (num_irqs_queued == num_irqs_handled) {
|
||||
++num_irqs_queued;
|
||||
if (netdev->event_callback) {
|
||||
netdev->event_callback(netdev, NETDEV_EVENT_ISR);
|
||||
}
|
||||
netdev_trigger_event_isr(netdev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,9 +41,8 @@ static void _irq_handler(void *arg)
|
||||
{
|
||||
netdev_t *dev = (netdev_t *) arg;
|
||||
|
||||
if (dev->event_callback) {
|
||||
dev->event_callback(dev, NETDEV_EVENT_ISR);
|
||||
}
|
||||
netdev_trigger_event_isr(dev);
|
||||
|
||||
((mrf24j40_t *)arg)->irq_flag = 1;
|
||||
}
|
||||
|
||||
|
@ -62,15 +62,11 @@ static void _rx_cb(void *arg, uint8_t c)
|
||||
if (dev->int_state == RN2XX3_INT_STATE_MAC_RX_MESSAGE) {
|
||||
/* RX state: closing RX buffer */
|
||||
dev->rx_buf[(dev->rx_size + 1) / 2] = 0;
|
||||
if (netdev->event_callback) {
|
||||
netdev->event_callback(netdev, NETDEV_EVENT_ISR);
|
||||
}
|
||||
netdev_trigger_event_isr(netdev);
|
||||
}
|
||||
else if (dev->int_state == RN2XX3_INT_STATE_MAC_TX) {
|
||||
/* still in TX state: transmission complete but no data received */
|
||||
if (netdev->event_callback) {
|
||||
netdev->event_callback(netdev, NETDEV_EVENT_ISR);
|
||||
}
|
||||
netdev_trigger_event_isr(netdev);
|
||||
}
|
||||
dev->resp_size = 0;
|
||||
dev->rx_size = 0;
|
||||
|
@ -64,9 +64,8 @@ static void _slip_rx_cb(void *arg, uint8_t byte)
|
||||
tsrb_add_one(&dev->inbuf, byte);
|
||||
check_end:
|
||||
if (byte == SLIPDEV_END) {
|
||||
if ((dev->state == SLIPDEV_STATE_NET) &&
|
||||
(dev->netdev.event_callback != NULL)) {
|
||||
dev->netdev.event_callback((netdev_t *)dev, NETDEV_EVENT_ISR);
|
||||
if (dev->state == SLIPDEV_STATE_NET) {
|
||||
netdev_trigger_event_isr((netdev_t*) dev);
|
||||
}
|
||||
dev->state = SLIPDEV_STATE_NONE;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ void isr_eth(void)
|
||||
ETH->DMASR = ETH_DMASR_RS | ETH_DMASR_NIS;
|
||||
mutex_unlock(&_rx);
|
||||
if (_netdev) {
|
||||
_netdev->event_callback(_netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(_netdev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,9 +221,7 @@ uint32_t sx127x_random(sx127x_t *dev)
|
||||
*/
|
||||
void sx127x_isr(netdev_t *dev)
|
||||
{
|
||||
if (dev->event_callback) {
|
||||
dev->event_callback(dev, NETDEV_EVENT_ISR);
|
||||
}
|
||||
netdev_trigger_event_isr(dev);
|
||||
}
|
||||
|
||||
static void sx127x_on_dio_isr(sx127x_t *dev, sx127x_flags_t flag)
|
||||
|
@ -106,9 +106,7 @@ static void extint(void *arg)
|
||||
{
|
||||
w5100_t *dev = (w5100_t *)arg;
|
||||
|
||||
if (dev->nd.event_callback) {
|
||||
dev->nd.event_callback(&dev->nd, NETDEV_EVENT_ISR);
|
||||
}
|
||||
netdev_trigger_event_isr(&dev->nd);
|
||||
}
|
||||
|
||||
void w5100_setup(w5100_t *dev, const w5100_params_t *params)
|
||||
|
@ -233,9 +233,7 @@ static void _rx_cb(void *arg, uint8_t c)
|
||||
dev->rx_buf[dev->rx_count++] = c;
|
||||
if (dev->rx_count == dev->rx_limit) {
|
||||
/* packet is complete */
|
||||
if (dev->event_callback) {
|
||||
dev->event_callback((netdev_t *)dev, NETDEV_EVENT_ISR);
|
||||
}
|
||||
netdev_trigger_event_isr((netdev_t*) dev);
|
||||
dev->int_state = XBEE_INT_STATE_IDLE;
|
||||
}
|
||||
break;
|
||||
|
@ -316,8 +316,8 @@ static void _store_frame_chunk(usbus_cdcecm_device_t *cdcecm)
|
||||
sizeof(size_t));
|
||||
memcpy(cdcecm->in_buf + cdcecm->len, buf, len);
|
||||
cdcecm->len += len;
|
||||
if (len < USBUS_CDCECM_EP_DATA_SIZE && cdcecm->netdev.event_callback) {
|
||||
cdcecm->netdev.event_callback(&cdcecm->netdev, NETDEV_EVENT_ISR);
|
||||
if (len < USBUS_CDCECM_EP_DATA_SIZE) {
|
||||
netdev_trigger_event_isr(&cdcecm->netdev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ void _test_trigger_recv(gnrc_netif_t *netif, const uint8_t *data,
|
||||
tmp_buffer_bytes = 0;
|
||||
}
|
||||
assert(dev->event_callback);
|
||||
dev->event_callback(dev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr(dev);
|
||||
}
|
||||
|
||||
static int _netdev_recv(netdev_t *dev, char *buf, int len, void *info)
|
||||
|
@ -247,7 +247,7 @@ bool _inject_4packet(uint32_t src, uint32_t dst, uint8_t proto, void *data,
|
||||
_netdev_buffer_size = sizeof(ethernet_hdr_t) + sizeof(struct ip_hdr) +
|
||||
data_len;
|
||||
mutex_unlock(&_netdev_buffer_mutex);
|
||||
((netdev_t *)&netdev)->event_callback((netdev_t *)&netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr((netdev_t *)&netdev);
|
||||
|
||||
return true;
|
||||
#else
|
||||
@ -279,7 +279,7 @@ bool _inject_6packet(const ipv6_addr_t *src, const ipv6_addr_t *dst,
|
||||
_netdev_buffer_size = sizeof(ethernet_hdr_t) + sizeof(ipv6_hdr_t) +
|
||||
data_len;
|
||||
mutex_unlock(&_netdev_buffer_mutex);
|
||||
((netdev_t *)&netdev)->event_callback((netdev_t *)&netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr((netdev_t *)&netdev);
|
||||
|
||||
return true;
|
||||
#else
|
||||
|
@ -259,7 +259,7 @@ bool _inject_4packet(uint32_t src, uint32_t dst, uint16_t src_port,
|
||||
_netdev_buffer_size = sizeof(ethernet_hdr_t) + sizeof(struct ip_hdr) +
|
||||
sizeof(udp_hdr_t) + data_len;
|
||||
mutex_unlock(&_netdev_buffer_mutex);
|
||||
((netdev_t *)&netdev)->event_callback((netdev_t *)&netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr((netdev_t *)&netdev);
|
||||
|
||||
return true;
|
||||
#else
|
||||
@ -308,7 +308,7 @@ bool _inject_6packet(const ipv6_addr_t *src, const ipv6_addr_t *dst,
|
||||
_netdev_buffer_size = sizeof(ethernet_hdr_t) + sizeof(ipv6_hdr_t) +
|
||||
sizeof(udp_hdr_t) + data_len;
|
||||
mutex_unlock(&_netdev_buffer_mutex);
|
||||
((netdev_t *)&netdev)->event_callback((netdev_t *)&netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr((netdev_t *)&netdev);
|
||||
|
||||
return true;
|
||||
#else
|
||||
|
@ -152,7 +152,7 @@ static int test_receive(void)
|
||||
/* register for GNRC_NETTYPE_UNDEF */
|
||||
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &me);
|
||||
/* fire ISR event */
|
||||
_dev.netdev.event_callback((netdev_t *)&_dev.netdev, NETDEV_EVENT_ISR);
|
||||
netdev_trigger_event_isr((netdev_t *)&_dev.netdev);
|
||||
/* wait for packet from MAC layer*/
|
||||
msg_receive(&msg);
|
||||
/* check message */
|
||||
|
Loading…
Reference in New Issue
Block a user