Date:2011-06-21 04:11:09 (8 years 5 months ago)
Author:Werner Almesberger
Commit:f7b9a18917b8ed913f33bda55a33a87cf419c352
Message: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
Files: atusb/fw/board.h (1 diff)
atusb/fw/board_app.c (2 diffs)
atusb/fw/ep0.c (1 diff)
atusb/fw/include/atusb/ep0.h (2 diffs)

Change Details

atusb/fw/board.h
8181void timer_init(void);
8282
8383int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res);
84void gpio_cleanup(void);
8485
8586void board_init(void);
8687void board_app_init(void);
atusb/fw/board_app.c
9393
9494int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res)
9595{
96    EIMSK = 0; /* must reset to recover INT_RF */
96    EIMSK = 0; /* recover INT_RF to ATUSB_GPIO_CLEANUP or an MCU reset */
9797
9898    switch (port) {
9999    case 1:
...... 
138138}
139139
140140
141void gpio_cleanup(void)
142{
143    EIMSK = 1 << 0;
144}
145
146
141147ISR(INT0_vect)
142148{
143149    static uint8_t irq;
atusb/fw/ep0.c
125125            return 0;
126126        usb_send(&eps[0], buf, 3, NULL, NULL);
127127        return 1;
128    case ATUSB_TO_DEV(ATUSB_GPIO_CLEANUP):
129        gpio_cleanup();
130        return 1;
128131
129132    case ATUSB_TO_DEV(ATUSB_SLP_TR):
130133        debug("ATUSB_SLP_TR\n");
atusb/fw/include/atusb/ep0.h
2727 * ->host ATUSB_TIMER - - #bytes (6)
2828 * ->host ATUSB_GPIO dir+data mask+p# 3
2929 * host-> ATUSB_SLP_TR - - 0
30 * host-> ATUSB_GPIO_CLEANUP - - 0
3031 *
3132 * host-> ATUSB_REG_WRITE value addr 0
3233 * ->host ATUSB_REG_READ - addr 1
...... 
8081    ATUSB_TIMER,
8182    ATUSB_GPIO,
8283    ATUSB_SLP_TR,
84    ATUSB_GPIO_CLEANUP,
8385    ATUSB_REG_WRITE = 0x20, /* transceiver group */
8486    ATUSB_REG_READ,
8587    ATUSB_BUF_WRITE,

Archive Download the corresponding diff file



interactive