Fix SPI SD card detect logic; Fix AVR USB device interrupt initialization

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3740 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2011-07-02 16:45:04 +00:00
parent 3af8169e0a
commit 65d6076e48
5 changed files with 28 additions and 23 deletions
+6 -3
View File
@@ -1846,6 +1846,9 @@
* arch/sim/src/up_romgetc.c: Used to test the basic logic to access strings * arch/sim/src/up_romgetc.c: Used to test the basic logic to access strings
without directly de-referencing a string pointer. without directly de-referencing a string pointer.
* arch/avr/src/avr/up_romget.c: Used to access strings that lie in the first * arch/avr/src/avr/up_romget.c: Used to access strings that lie in the first
64Kb of FLASH. 64Kb of FLASH (But I still haven't figured out how to get strings to reside in
FLASH without using the PROGMEM attribute).
* configs/teensy/src/up_spi.c: Correct reading of SD CD and WP pins (was reading
the wrong register. AVR SPI now appears to be functional.
* arch/avr/src/at90usb/at90usb_usbdev.c: Correct USB initialization. Interrupts
were being enabled BEFORE the interrupt handler was attached.
+14 -12
View File
@@ -2745,14 +2745,6 @@ void up_usbinitialize(void)
{ {
usbtrace(TRACE_DEVINIT, 0); usbtrace(TRACE_DEVINIT, 0);
/* Shutdown the USB interface to put it in a known initial state */
avr_usbshutdown();
/* Select USB device mode */
UHWCON |= (1 << UIMOD);
/* Initialize the device state structure */ /* Initialize the device state structure */
memset(&g_usbdev, 0, sizeof(struct avr_usbdev_s)); memset(&g_usbdev, 0, sizeof(struct avr_usbdev_s));
@@ -2760,10 +2752,6 @@ void up_usbinitialize(void)
g_usbdev.usbdev.ep0 = &g_usbdev.eplist[AVR_EP0].ep; g_usbdev.usbdev.ep0 = &g_usbdev.eplist[AVR_EP0].ep;
g_usbdev.epavail = AVR_ALL_EPS & ~(1 << AVR_EP0); g_usbdev.epavail = AVR_ALL_EPS & ~(1 << AVR_EP0);
/* Reset the interface to force re-enumeration */
avr_usbreset();
/* Attach USB controller general interrupt handler */ /* Attach USB controller general interrupt handler */
if (irq_attach(AT90USB_IRQ_USBGEN, avr_geninterrupt) != 0) if (irq_attach(AT90USB_IRQ_USBGEN, avr_geninterrupt) != 0)
@@ -2780,6 +2768,20 @@ void up_usbinitialize(void)
goto errout; goto errout;
} }
/* Shutdown the USB interface to put it in a known initial state */
avr_usbshutdown();
/* Select USB device mode */
UHWCON |= (1 << UIMOD);
/* Reset the interface to force re-enumeration (the reset operation
* enables interrupts.
*/
avr_usbreset();
/* Set the VBUS pad */ /* Set the VBUS pad */
USBCON |= (1 << OTGPADE); USBCON |= (1 << OTGPADE);
+1 -1
View File
@@ -183,7 +183,7 @@ Teensy SPI Connection
-- ---- -- ------------------------- ------- -- ---- -- ------------------------- -------
J2 NAME PIN NAME PAD J2 NAME PIN NAME PAD
-- ---- -- ------------------------- ------- -- ---- -- ------------------------- -------
1 VIN -- Connected to USB +RV 1 VIN -- Connected to USB +5V
2 GND -- Connected to USB GND 2 GND -- Connected to USB GND
3 3V3 -- Not used --- 3 3V3 -- Not used ---
4 NC -- Not used 4 NC -- Not used
+1 -1
View File
@@ -179,7 +179,7 @@ void avr_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool select
uint8_t avr_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid) uint8_t avr_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{ {
uint8_t ret = 0; uint8_t ret = 0;
uint8_t regval = PORTB; uint8_t regval = PINB;
/* Both the CD and WP pins are pull high by the AT90USB and will be /* Both the CD and WP pins are pull high by the AT90USB and will be
* grounded it a card is inserted or write protected. * grounded it a card is inserted or write protected.
+3 -3
View File
@@ -268,9 +268,9 @@ CONFIG_ARCH_LOWPUTC=y
CONFIG_RR_INTERVAL=200 CONFIG_RR_INTERVAL=200
CONFIG_SCHED_INSTRUMENTATION=n CONFIG_SCHED_INSTRUMENTATION=n
CONFIG_TASK_NAME_SIZE=0 CONFIG_TASK_NAME_SIZE=0
CONFIG_START_YEAR=2010 CONFIG_START_YEAR=2011
CONFIG_START_MONTH=6 CONFIG_START_MONTH=7
CONFIG_START_DAY=17 CONFIG_START_DAY=2
CONFIG_GREGORIAN_TIME=n CONFIG_GREGORIAN_TIME=n
CONFIG_JULIAN_TIME=n CONFIG_JULIAN_TIME=n
CONFIG_DEV_CONSOLE=y CONFIG_DEV_CONSOLE=y