From 852aaf1b661beaedc22c0a233d68e7e08e5e970d Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 13 Feb 2013 09:30:21 -0300 Subject: [PATCH] atusb/fw/: reset MAC state on ATUSB_RF_RESET --- atusb/fw/ep0.c | 1 + atusb/fw/mac.c | 10 +++++++++- atusb/fw/mac.h | 5 +++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/atusb/fw/ep0.c b/atusb/fw/ep0.c index 4b54873..5bbe177 100644 --- a/atusb/fw/ep0.c +++ b/atusb/fw/ep0.c @@ -96,6 +96,7 @@ static int my_setup(const struct setup_request *setup) case ATUSB_TO_DEV(ATUSB_RF_RESET): debug("ATUSB_RF_RESET\n"); reset_rf(); + mac_reset(); //ep_send_zlp(EP_CTRL); return 1; diff --git a/atusb/fw/mac.c b/atusb/fw/mac.c index 05457a4..7a63dbc 100644 --- a/atusb/fw/mac.c +++ b/atusb/fw/mac.c @@ -37,7 +37,7 @@ static uint8_t reg_read(uint8_t reg) spi_begin(); spi_send(AT86RF230_REG_READ | reg); - value= spi_recv(); + value = spi_recv(); spi_end(); return value; @@ -167,3 +167,11 @@ int mac_tx(uint16_t flags, uint16_t len) usb_recv(&eps[0], tx_buf, len, do_tx, NULL); return 1; } + + +void mac_reset(void) +{ + mac_irq = NULL; + txing = 0; + queued_tx_ack = 0; +} diff --git a/atusb/fw/mac.h b/atusb/fw/mac.h index b75833e..b6eed97 100644 --- a/atusb/fw/mac.h +++ b/atusb/fw/mac.h @@ -1,8 +1,8 @@ /* * fw/mac.h - HardMAC functions * - * Written 2011 by Werner Almesberger - * Copyright 2011 Werner Almesberger + * Written 2011, 2013 by Werner Almesberger + * Copyright 2011, 2013 Werner Almesberger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,5 +20,6 @@ extern int (*mac_irq)(void); int mac_rx(int on); int mac_tx(uint16_t flags, uint16_t len); +void mac_reset(void); #endif /* !MAC_H */