1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-22 19:20:41 +02:00

atusb/fw/: new request ATUSB_GPIO_CLEANUP to re-enable INT0

- board.h (gpio_cleanup), board_app.c (gpio_cleanup): restore INT0
  when done manipulating GPIOs
- board.c (gpio): updated comment explaining how to restore INT0
- include/atusb/ep0.h (enum atspi_requests), ep0.c
  (ATUSB_GPIO_CLEANUP): new request to return to normal operation
  after ATUSB_GPIO
This commit is contained in:
Werner Almesberger 2011-06-20 23:11:09 -03:00
parent f8f2f890d9
commit f7b9a18917
4 changed files with 13 additions and 1 deletions

View File

@ -81,6 +81,7 @@ uint64_t timer_read(void);
void timer_init(void); void timer_init(void);
int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res); int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res);
void gpio_cleanup(void);
void board_init(void); void board_init(void);
void board_app_init(void); void board_app_init(void);

View File

@ -93,7 +93,7 @@ void timer_init(void)
int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res) int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res)
{ {
EIMSK = 0; /* must reset to recover INT_RF */ EIMSK = 0; /* recover INT_RF to ATUSB_GPIO_CLEANUP or an MCU reset */
switch (port) { switch (port) {
case 1: case 1:
@ -138,6 +138,12 @@ int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res)
} }
void gpio_cleanup(void)
{
EIMSK = 1 << 0;
}
ISR(INT0_vect) ISR(INT0_vect)
{ {
static uint8_t irq; static uint8_t irq;

View File

@ -125,6 +125,9 @@ static int my_setup(const struct setup_request *setup)
return 0; return 0;
usb_send(&eps[0], buf, 3, NULL, NULL); usb_send(&eps[0], buf, 3, NULL, NULL);
return 1; return 1;
case ATUSB_TO_DEV(ATUSB_GPIO_CLEANUP):
gpio_cleanup();
return 1;
case ATUSB_TO_DEV(ATUSB_SLP_TR): case ATUSB_TO_DEV(ATUSB_SLP_TR):
debug("ATUSB_SLP_TR\n"); debug("ATUSB_SLP_TR\n");

View File

@ -27,6 +27,7 @@
* ->host ATUSB_TIMER - - #bytes (6) * ->host ATUSB_TIMER - - #bytes (6)
* ->host ATUSB_GPIO dir+data mask+p# 3 * ->host ATUSB_GPIO dir+data mask+p# 3
* host-> ATUSB_SLP_TR - - 0 * host-> ATUSB_SLP_TR - - 0
* host-> ATUSB_GPIO_CLEANUP - - 0
* *
* host-> ATUSB_REG_WRITE value addr 0 * host-> ATUSB_REG_WRITE value addr 0
* ->host ATUSB_REG_READ - addr 1 * ->host ATUSB_REG_READ - addr 1
@ -80,6 +81,7 @@ enum atspi_requests {
ATUSB_TIMER, ATUSB_TIMER,
ATUSB_GPIO, ATUSB_GPIO,
ATUSB_SLP_TR, ATUSB_SLP_TR,
ATUSB_GPIO_CLEANUP,
ATUSB_REG_WRITE = 0x20, /* transceiver group */ ATUSB_REG_WRITE = 0x20, /* transceiver group */
ATUSB_REG_READ, ATUSB_REG_READ,
ATUSB_BUF_WRITE, ATUSB_BUF_WRITE,