From 51fe47ed8af74fe55922344dea83bd4326816994 Mon Sep 17 00:00:00 2001 From: bsongis Date: Tue, 4 Mar 2014 17:14:35 +0100 Subject: [PATCH] 3 files removed --- radio/bootloader/Makefile | 2 +- radio/bootloader/boot.cpp | 4 +- radio/bootloader/include/diskio.h | 6 +- radio/bootloader/include/hal.h | 254 ---------------------- radio/bootloader/massstorage.cpp | 233 -------------------- radio/bootloader/sdcard_driver.cpp | 71 ------ radio/bootloader/usbd_storage_msd.cpp | 9 +- radio/src/targets/taranis/board_taranis.h | 11 +- radio/src/targets/taranis/diskio.cpp | 22 +- radio/src/targets/taranis/hal.h | 4 +- 10 files changed, 35 insertions(+), 581 deletions(-) delete mode 100644 radio/bootloader/include/hal.h delete mode 100644 radio/bootloader/massstorage.cpp delete mode 100644 radio/bootloader/sdcard_driver.cpp diff --git a/radio/bootloader/Makefile b/radio/bootloader/Makefile index 50e327181..886d06bb2 100644 --- a/radio/bootloader/Makefile +++ b/radio/bootloader/Makefile @@ -141,7 +141,7 @@ CPPSRC = lcd_driver.cpp \ driversboot.cpp \ logicioboot.cpp \ ff.cpp \ - x9ddiskio.cpp \ + ../src/targets/taranis/diskio.cpp \ ../src/targets/taranis/usbd_usr.cpp \ usbd_storage_msd.cpp \ lcdboot.cpp \ diff --git a/radio/bootloader/boot.cpp b/radio/bootloader/boot.cpp index 9305a9064..1c3dd2673 100644 --- a/radio/bootloader/boot.cpp +++ b/radio/bootloader/boot.cpp @@ -819,7 +819,7 @@ extern uint8_t OptrexDisplay ; #ifdef PCBTARANIS // SD card detect pin - configure_pins( GPIO_Pin_CP, PIN_PORTD | PIN_INPUT | PIN_PULLUP ) ; + configure_pins( SD_PRESENT_GPIO_Pin, PIN_PORTD | PIN_INPUT | PIN_PULLUP ) ; disk_initialize( 0 ) ; sdInit() ; unlockFlash() ; @@ -859,7 +859,7 @@ extern uint8_t OptrexDisplay ; lcd_puts_Pleft( 0, "\006Boot Loader" ) ; #endif - if ( sd_card_ready() ) + if ( sdMounted() ) { #ifdef PCBSKY lcd_puts_Pleft( 0, "\014Ready" ) ; diff --git a/radio/bootloader/include/diskio.h b/radio/bootloader/include/diskio.h index b05e8073c..e091b709c 100644 --- a/radio/bootloader/include/diskio.h +++ b/radio/bootloader/include/diskio.h @@ -76,12 +76,11 @@ typedef enum { /*---------------------------------------*/ /* Prototypes for disk control functions */ -DSTATUS disk_initialize (BYTE); -DSTATUS disk_status (BYTE); - #ifdef __cplusplus extern "C" { #endif +DSTATUS disk_initialize (BYTE); +DSTATUS disk_status (BYTE); DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE); DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE); DRESULT disk_ioctl (BYTE, BYTE, BYTE*); @@ -164,6 +163,7 @@ extern void sd_poll_10mS( void ) ; #ifdef PCBTARANIS extern void sdPoll10ms( void ) ; extern void sdInit( void ) ; +uint32_t sdMounted(void); #endif extern uint32_t sd_card_ready( void ) ; extern uint32_t sd_read_block( uint32_t block_no, uint32_t *data ) ; diff --git a/radio/bootloader/include/hal.h b/radio/bootloader/include/hal.h deleted file mode 100644 index 8bad5aa6e..000000000 --- a/radio/bootloader/include/hal.h +++ /dev/null @@ -1,254 +0,0 @@ -#ifndef _HAL_ -#define _HAL_ - -/* - * GPIOS - */ - -#define RCC_AHB1Periph_GPIOBUTTON (RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE) - -// Keys -#define PIN_BUTTON_PLUS GPIO_Pin_10 //SW3 PE.10 -#define PIN_BUTTON_MINUS GPIO_Pin_11 //SW2 PE.11 -#define PIN_BUTTON_ENTER GPIO_Pin_12 //SW1 PE.12 -#define PIN_BUTTON_MENU GPIO_Pin_7 //SW4 PD.07 -#define PIN_BUTTON_EXIT GPIO_Pin_2 //SW5 PD.02 -#define PIN_BUTTON_PAGE GPIO_Pin_3 //SW6 PD.03 - -// Trims -#define PIN_TRIM1_UP GPIO_Pin_3 //PC.03 -#define PIN_TRIM1_DN GPIO_Pin_2 //PC.02 -#define PIN_TRIM2_UP GPIO_Pin_1 //PC.01 -#define PIN_TRIM2_DN GPIO_Pin_13 //PC.13 -#define PIN_TRIM3_UP GPIO_Pin_4 //PE.04 -#define PIN_TRIM3_DN GPIO_Pin_3 //PE.03 -#define PIN_TRIM4_UP GPIO_Pin_6 //PE.06 -#define PIN_TRIM4_DN GPIO_Pin_5 //PE.05 - -// Switches -#if defined(REV3) -#define PIN_SW_A_L GPIO_Pin_14 //PE.14 -#define PIN_SW_B_H GPIO_Pin_3 //PB.03 -#define PIN_SW_B_L GPIO_Pin_4 //PB.04 -#define PIN_SW_C_H GPIO_Pin_5 //PB.05 -#define PIN_SW_C_L GPIO_Pin_6 //PB.06 -#define PIN_SW_D_H GPIO_Pin_7 //PB.07 -#define PIN_SW_D_L GPIO_Pin_2 //PE.02 -#define PIN_SW_E_H GPIO_Pin_0 //PB.00 -#define PIN_SW_E_L GPIO_Pin_5 //PA.05 -#define PIN_SW_F_H GPIO_Pin_7 //PE.07 -#define PIN_SW_F_L GPIO_Pin_1 //PB.01 -#define PIN_SW_G_H GPIO_Pin_9 //PE.09 -#define PIN_SW_G_L GPIO_Pin_8 //PE.08 -#define PIN_SW_H_L GPIO_Pin_13 //PE.13 -#else -#define PIN_SW_A_L GPIO_Pin_0 //PE.00 -#define PIN_SW_A_H GPIO_Pin_5 //PB.05 -#define PIN_SW_B_L GPIO_Pin_2 //PE.02 -#define PIN_SW_B_H GPIO_Pin_1 //PE.01 -#define PIN_SW_C_L GPIO_Pin_5 //PA.05 -#define PIN_SW_C_H GPIO_Pin_15 //PE.15 -#define PIN_SW_D_L GPIO_Pin_1 //PB.01 -#define PIN_SW_D_H GPIO_Pin_7 //PE.07 -#define PIN_SW_E_L GPIO_Pin_4 //PB.04 -#define PIN_SW_E_H GPIO_Pin_3 //PB.03 -#define PIN_SW_F GPIO_Pin_14 //PE.14 -#define PIN_SW_G_L GPIO_Pin_8 //PE.08 -#define PIN_SW_G_H GPIO_Pin_9 //PE.09 -#define PIN_SW_H GPIO_Pin_13 //PE.13 -#endif -// ADC -#define PIN_STK_J1 GPIO_Pin_0 //PA.00 -#define PIN_STK_J2 GPIO_Pin_1 //PA.01 -#define PIN_STK_J3 GPIO_Pin_2 //PA.02 -#define PIN_STK_J4 GPIO_Pin_3 //PA.03 -#define PIN_SLD_J1 GPIO_Pin_4 //PC.04 -#define PIN_SLD_J2 GPIO_Pin_5 //PC.05 -#define PIN_FLP_J1 GPIO_Pin_6 //PA.06 -#define PIN_FLP_J2 GPIO_Pin_0 //PB.00 -#define PIN_MVOLT GPIO_Pin_0 //PC.00 -#define RCC_AHB1Periph_GPIOADC RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC - -// DAC -#define PIN_AUDIO_DAC GPIO_Pin_4 //PA.04 - -// Power_OFF Delay and LED -#define PIN_PWR_LED GPIO_Pin_6 //PC.06 -#define PIN_PWR_STATUS GPIO_Pin_1 //PD.01 -#define PIN_MCU_PWR GPIO_Pin_0 //PD.00 -#define RCC_AHB1Periph_GPIOPWR RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD -#define GPIOPWRLED GPIOC -#define GPIOPWR GPIOD -#define PIN_INT_RF_PWR GPIO_Pin_15 -#define PIN_EXT_RF_PWR GPIO_Pin_8 - - -// Smart-Port -#define PIN_SPORT_ON GPIO_Pin_4 //PD.04 -#define PIN_SPORT_TX GPIO_Pin_5 //PD.05 -#define PIN_SPORT_RX GPIO_Pin_6 //PD.06 - -// Trainer Port -#define GPIO_TR_INOUT GPIOC -#define PIN_TR_PPM_IN GPIO_Pin_8 //PC.08 -#define PIN_TR_PPM_OUT GPIO_Pin_9 //PC.09 -#define GPIOTRNDET GPIOA -#define PIN_TRNDET GPIO_Pin_8 - - - -// Cppm -#define RCC_AHB1Periph_GPIOCPPM RCC_AHB1Periph_GPIOA -#define RCC_AHB1Periph_GPIO_INTPPM RCC_AHB1Periph_GPIOA -#define PORT_INTPPM PIN_PORTA -#define GPIO_INTPPM GPIOA -#define PIN_INTPPM_OUT GPIO_Pin_10 //PA.10 -#define PIN_CPPM_OUT GPIO_Pin_8 //PA.08 -#define GPIOCPPM GPIOA -#define GPIO_PinSource_CPPM GPIO_PinSource8 -#define PIN_EXTPPM_OUT GPIO_Pin_7 //PA.07 -#define PORT_EXTPPM PIN_PORTA -#define GPIO_PinSource_EXTPPM GPIO_PinSource7 - -// Heart Beat -#define PIN_HEART_BEAT GPIO_Pin_7 //PC.07 - -// Update UART----RS232 ---UART3 -#define PIN_UPDATE_UART_TX GPIO_Pin_10 //PB.10 -#define PIN_UPDATE_UART_RX GPIO_Pin_11 //PB.11 - -// USB_OTG -#define PIN_FS_VBUS GPIO_Pin_9 //PA.09 -#define PIN_FS_ID GPIO_Pin_10 //PA.10 -#define PIN_FS_DM GPIO_Pin_11 //PA.11 -#define PIN_FS_DP GPIO_Pin_12 //PA.12 - -// BackLight PB8 -#define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOB -#define GPIO_Pin_BL GPIO_Pin_8 //PB.08 -#define GPIOBL GPIOB -#define GPIO_PinSource_BL GPIO_PinSource8 - -// LCD GPIOD 10-14 -#define RCC_AHB1Periph_LCD RCC_AHB1Periph_GPIOD -#define GPIO_LCD GPIOD -#define PIN_LCD_MOSI GPIO_Pin_10 //PD.10 -#define PIN_LCD_CLK GPIO_Pin_11 //PD.11 -#define PIN_LCD_NCS GPIO_Pin_14 //PD.14 -#define PIN_LCD_A0 GPIO_Pin_13 //PD.13 -#define PIN_LCD_RST GPIO_Pin_12 //pd12 test //RESET occurs when powered up,but should delay before initialize - -// Audio----I2S3 -//#define CODEC_I2S_ADDRESS 0x4000380C -#define CODEC_I2S SPI3 -#define CODEC_I2S_CLK RCC_APB1Periph_SPI3 -#define CODEC_I2S_GPIO_AF GPIO_AF_SPI3 -#define CODEC_I2S_IRQ SPI3_IRQn -#define CODEC_I2S_GPIO_CLOCK (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC )//| RCC_AHB1Periph_GPIOE) -#define CODEC_I2S_WS_PIN GPIO_Pin_15 //PA.15 -#define CODEC_I2S_SCK_PIN GPIO_Pin_10 //PC.10 -#define CODEC_I2S_SD_PIN GPIO_Pin_12 //PC.12 -#define CODEC_I2S_MCK_PIN GPIO_Pin_6 //DISABLED -#define CODEC_I2S_WS_PINSRC GPIO_PinSource15 -#define CODEC_I2S_SCK_PINSRC GPIO_PinSource10 -#define CODEC_I2S_SD_PINSRC GPIO_PinSource12 -#define CODEC_I2S_MCK_PINSRC GPIO_PinSource6 -#define CODEC_I2S_GPIO GPIOC -#define CODEC_I2S_MCK_GPIO GPIOC -#define CODEC_I2S_WS_GPIO GPIOA -#define CODEC_I2S_MUTE GPIO_Pin_11 //PC.11 -//#define CODEC_I2S_FLT GPIO_Pin_ //IIR/FIR -//#define CODEC_I2S_MODE GPIO_Pin_ //Connect to GND=I2S_STANDARD - -// Eeprom 5137 -#define I2C_EE_GPIO GPIOB -#define I2C_EE_WP_GPIO GPIOB -#define I2C_EE_GPIO_CLK RCC_AHB1Periph_GPIOB -#define I2C_EE_SCL GPIO_Pin_6 //PB6 -#define I2C_EE_SDA GPIO_Pin_7 //PB7 -#define I2C_EE_WP GPIO_Pin_9 //PB9 - -// SD---spi2 -#define SPI_SD SPI2 -#define GPIO_AF_SD GPIO_AF_SPI2 -#define RCC_AHB1Periph_GPIO_CS RCC_AHB1Periph_GPIOB -#define GPIO_SPI_SD GPIOB -#define GPIO_Pin_SPI_SD_CS GPIO_Pin_12 //PB.12 -#define GPIO_Pin_SPI_SD_SCK GPIO_Pin_13 //PB.13 -#define GPIO_Pin_SPI_SD_MISO GPIO_Pin_14 //PB.14 -#define GPIO_Pin_SPI_SD_MOSI GPIO_Pin_15 //PB.15 -#define GPIO_PinSource_CS GPIO_PinSource12 -#define GPIO_PinSource_SCK GPIO_PinSource13 -#define GPIO_PinSource_MISO GPIO_PinSource14 -#define GPIO_PinSource_MOSI GPIO_PinSource15 -#define RCC_APBPeriphClockCmd_SPI_SD RCC_APB1PeriphClockCmd -#define RCC_APBPeriph_SPI_SD RCC_APB1Periph_SPI2 -#define RCC_AHBxPeriph_GPIO_WP RCC_AHB1Periph_GPIOD -#define RCC_AHBxPeriph_GPIO_CP RCC_AHB1Periph_GPIOD -#define GPIO_Mode_WP GPIO_Mode_OUT//lock? -#define GPIO_Mode_CP GPIO_Mode_IN // -#define GPIO_Pin_WP GPIO_Pin_8 //PD.08 -#define GPIO_Pin_CP GPIO_Pin_9 //PD.09 -#define GPIO_CTL_SD GPIOD - -// Audio----I2S3-----SPI3 -#define CODEC_MCLK_DISABLED -#define CODEC_USE_INT -//#define CODEC_USE_DMA -#define AudioFreq I2S_AudioFreq_44k - - -// EEPROM and CAT5137 -//#define EE_M24C08 /* Support the device: M24C08. */ -//#define EE_M24C64_32 /* Support the devices: M24C32 and M24C64 */ -#define I2C_Speed 200000 -#define I2C_FLASH_PAGESIZE 64 -#define I2C_EEPROM_ADDRESS 0xA2 -#define I2C_CAT5137_ADDRESS 0x5C //0101110 - -//#if defined (EE_M24C08) -// #define I2C_FLASH_PAGESIZE (16) -//#elif defined (EE_M24C64_32) -// #define I2C_FLASH_PAGESIZE (32) -//#endif - -//#ifdef EE_M24C64_32 -// #define EEPROM_HW_ADDRESS 0xA0 /* E0 = E1 = E2 = 0 */ -//#elif defined (EE_M24C08) -////#define EEPROM_Block0_ADDRESS 0xA0 /* 000*/ -//#define EEPROM_Block1_ADDRESS 0xA2 /* E3 E2 E1= 001 */ -////#define EEPROM_Block2_ADDRESS 0xA4 /* 010 */ -////#define EEPROM_Block3_ADDRESS 0xA6 /* 011 */ -//#endif - -//#define USE_CAT5137 /*Support the Volume Control*/ - -//#ifdef USE_CAT5137 -//#define I2C_CAT5137_ADDRESS 0x5C//0101110 -//#endif - -// SD card----SPI2 -// demo uses a command line option to define this (see Makefile): -// #define STM32_SD_USE_DMA -#ifdef STM32_SD_USE_DMA -// #warning "Information only: using DMA" -#pragma message "*** Using DMA ***" -#endif - -/* set to 1 to provide a disk_ioctrl function even if not needed by the FatFs */ -#define STM32_SD_DISK_IOCTRL_FORCE (0) - -#define CARD_SUPPLY_SWITCHABLE (0) //0£¬power on not depend any IO -#define SOCKET_WP_CONNECTED (0) -#define SOCKET_CP_CONNECTED (0) - -#define SPI_BaudRatePrescaler_SPI_SD SPI_BaudRatePrescaler_4 // - for SPI1 and full-speed APB2: 60MHz/4 =15MHZ < 20MHZ - -// Selectable -// DMA -#define DMA_Channel_SPI_SD_RX DMA1_Channel2 -#define DMA_Channel_SPI_SD_TX DMA1_Channel3 -#define DMA_FLAG_SPI_SD_TC_RX DMA1_FLAG_TC2 -#define DMA_FLAG_SPI_SD_TC_TX DMA1_FLAG_TC3 - -#endif diff --git a/radio/bootloader/massstorage.cpp b/radio/bootloader/massstorage.cpp deleted file mode 100644 index 92d80ddf3..000000000 --- a/radio/bootloader/massstorage.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Authors (alphabetical order) - * - Bertrand Songis - * - Bryan J. Rentoul (Gruvin) - * - Cameron Weeks - * - Erez Raviv - * - Jean-Pierre Parisy - * - Karl Szmutny - * - Michael Blandford - * - Michal Hlavinka - * - Pat Mackenzie - * - Philip Moss - * - Rob Thomson - * - Romolo Manfredini - * - Thomas Husterer - * - * open9x is based on code named - * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, - * er9x by Erez Raviv: http://code.google.com/p/er9x/, - * and the original (and ongoing) project by - * Thomas Husterer, th9x: http://code.google.com/p/th9x/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include "radio.h" -#include "board.h" -//#include "debug.h" -//#include "Audio.h" - -//#ifndef SIMU -//#include "CoOS.h" -//#endif - -#ifndef SIMU - -extern "C" { -#include "MSDDriver.h" -extern unsigned char MEDSdcard_Initialize(Media *media, unsigned char mciID); -} - -/** Size of one block in bytes. */ -#define BLOCK_SIZE 512 - -/** Size of the MSD IO buffer in bytes (6K, more the better). */ -#define MSD_BUFFER_SIZE (12*BLOCK_SIZE) - -/** LUN read/write buffer. */ -unsigned char msdBuffer[MSD_BUFFER_SIZE]; - -unsigned int msdReadTotal=0, msdWriteTotal=0; - -static void ConfigureUsbClock(void) -{ - /* Enable PLLB for USB */ - PMC->CKGR_PLLBR = CKGR_PLLBR_DIVB(1) - | CKGR_PLLBR_MULB(7) - | CKGR_PLLBR_PLLBCOUNT; - while((PMC->PMC_SR & PMC_SR_LOCKB) == 0); // TODO && (timeout++ < CLOCK_TIMEOUT)); - /* USB Clock uses PLLB */ - PMC->PMC_USB = PMC_USB_USBDIV(1) /* /2 */ - | PMC_USB_USBS; /* PLLB */ -} - -/** Maximum number of LUNs which can be defined. */ -#define MAX_LUNS 2 - -/** Media index for different disks */ -#define DRV_SDMMC 0 /** SD card */ -#define DRV_EEPROM 1 /** EEPROM */ - -Media medias[MAX_LUNS]; - - -/*---------------------------------------------------------------------------- - * Local variables - *----------------------------------------------------------------------------*/ - -#ifdef HID - -uint8_t hid_iBuffer[64] ; -uint8_t hid_oBuffer[64] ; - -static void hid_transfer() -{ - uint32_t dwCnt=0 ; - uint32_t dwLen ; - - dwLen = HIDDTransferDriver_Read( hid_iBuffer, 64 ) ; - if ( dwLen ) - { -// printf( "Data In(%u):", (unsigned int)dwLen ) ; -// _ShowBuffer( iBuffer, dwLen ) ; - -// bmLEDs = iBuffer[0] ; -// update = 1 ; - } - - dwLen = HIDDTransferDriver_ReadReport( iBuffer, 64 ) ; - if ( dwLen ) - { -// printf( "Report In(%u):", (unsigned int)dwLen ) ; -// _ShowBuffer( iBuffer, dwLen ) ; - -// bmLEDs = iBuffer[0] ; -// update = 1 ; - } - - oBuffer[0] = 0x80 ; - if ( PIO_Get( &pinsButtons[PUSHBUTTON_BP1]) == 0 ) - { - oBuffer[0] |= 0x01 ; - } - if ( PIO_Get( &pinsButtons[PUSHBUTTON_BP2] ) == 0 ) - { - oBuffer[0] |= 0x02 ; - } - - sprintf( (char*)&oBuffer[5], ":%04x:%05u!", (unsigned int)dwCnt, (unsigned int)dwCnt ) ; - oBuffer[1] = (uint8_t)(dwCnt) ; - oBuffer[2] = (uint8_t)(dwCnt >> 8) ; - oBuffer[3] = (uint8_t)(dwCnt >> 16) ; - oBuffer[4] = (uint8_t)(dwCnt >> 24) ; - if ( USBD_STATUS_SUCCESS == HIDDTransferDriver_Write( oBuffer, 64, 0, 0 ) ) - { - dwCnt ++ ; - } -} - -#endif - - - - -/** Device LUNs. */ -MSDLun luns[MAX_LUNS]; - -static void MSDCallbacks_Data( unsigned char flowDirection, unsigned int dataLength, - unsigned int fifoNullCount, unsigned int fifoFullCount ) -{ -#if 0 - if (flowDirection) - msdReadTotal += dataLength; - else - msdWriteTotal += dataLength; -#endif -} - -extern "C" unsigned char EEPROM_Initialize(Media *media, unsigned char mciID) ; -extern uint32_t sd_card_ready( void ) ; - -void usbMassStorage() -{ - static bool initialized = false ; - static bool active = false ; - - if ( PIOC->PIO_PDSR & 0x02000000 ) - { - // TRACE_DEBUG("usbMassStorage\n\r"); - - if (!initialized) - { - ConfigureUsbClock(); - /* Initialize LUN */ - MEDSdcard_Initialize(&(medias[DRV_SDMMC]), 0); - EEPROM_Initialize(&(medias[DRV_EEPROM]), 0); - LUN_Init(&(luns[DRV_SDMMC]), sd_card_ready() ? &(medias[DRV_SDMMC]) : 0 , - msdBuffer, MSD_BUFFER_SIZE, - 0, 0, 0, 0, - MSDCallbacks_Data); - - LUN_Init(&(luns[DRV_EEPROM]), &(medias[DRV_EEPROM]), - msdBuffer, MSD_BUFFER_SIZE, - 0, 0, 0, 0, - MSDCallbacks_Data); - - /* BOT driver initialization */ - MSDDriver_Initialize( luns, 2 ) ; - // VBus_Configure(); - USBD_Connect(); - initialized = true; - } - - if ( active == false ) - { -#ifndef BOOT - CoSchedLock() ; - if ( Voice.VoiceLock == 0 ) - { - Voice.VoiceLock = 1 ; -#endif - active = true ; -#ifndef BOOT - } - CoSchedUnlock() ; -#endif - } - if ( active ) - { - /* Mass storage state machine */ - for (uint8_t i=0; i<50; i++) - { -#ifdef HID - hid_transfer() ; -#endif - MSDDriver_StateMachine() ; - } - } - } - else - { - if ( active ) - { - active = false ; -#ifndef BOOT - Voice.VoiceLock = 0 ; -#endif - } - - msdReadTotal = 0; - msdWriteTotal = 0; - } -} - -#endif diff --git a/radio/bootloader/sdcard_driver.cpp b/radio/bootloader/sdcard_driver.cpp deleted file mode 100644 index c437a7f8b..000000000 --- a/radio/bootloader/sdcard_driver.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Authors (alphabetical order) - * - Bertrand Songis - * - Bryan J. Rentoul (Gruvin) - * - Cameron Weeks - * - Erez Raviv - * - Jean-Pierre Parisy - * - Karl Szmutny - * - Michael Blandford - * - Michal Hlavinka - * - Pat Mackenzie - * - Philip Moss - * - Rob Thomson - * - Romolo Manfredini - * - Thomas Husterer - * - * open9x is based on code named - * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, - * er9x by Erez Raviv: http://code.google.com/p/er9x/, - * and the original (and ongoing) project by - * Thomas Husterer, th9x: http://code.google.com/p/th9x/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include -#include "diskio.h" -#include "radio.h" -#include "drivers.h" -#include "logicio.h" - -// SD Card routines - -#define MCI_INITIAL_SPEED 400000 - -void init_SDcard() -{ -#ifndef SIMU - configure_pins( 0xFC000000, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_C | PIN_PORTA | PIN_NO_PULLUP ) ; - configure_pins( PIO_PB7, PIN_INPUT | PIN_PORTB | PIN_NO_PULLUP | PIN_NO_PULLDOWN ) ; - - unsigned short clkDiv; - Hsmci *pMciHw = HSMCI ; - - /* Enable the MCI peripheral */ - PMC->PMC_PCER0 |= 1 << ID_HSMCI ; // Enable peripheral clock to HSMCI - pMciHw->HSMCI_CR = HSMCI_CR_SWRST; /* Reset the MCI */ - pMciHw->HSMCI_CR = HSMCI_CR_MCIDIS | HSMCI_CR_PWSDIS; /* Disable the MCI */ - pMciHw->HSMCI_IDR = 0xFFFFFFFF; /* Disable all the interrupts */ - pMciHw->HSMCI_DTOR = HSMCI_DTOR_DTOCYC_Msk | HSMCI_DTOR_DTOMUL_Msk ; /* Set the Data Timeout Register */ - pMciHw->HSMCI_CSTOR = HSMCI_CSTOR_CSTOCYC_Msk | HSMCI_CSTOR_CSTOMUL_Msk ; /* CSTOR ? */ - /* Set the Mode Register: 400KHz for MCK = 48MHz (CLKDIV = 58) */ - clkDiv = (Master_frequency / (MCI_INITIAL_SPEED * 2)) - 1; - pMciHw->HSMCI_MR = clkDiv | (7 << 8) ; - - /* Set the SDCard Register 1-bit, slot A */ - pMciHw->HSMCI_SDCR = HSMCI_SDCR_SDCSEL_SLOTA | HSMCI_SDCR_SDCBUS_1 ; - /* Enable the MCI and the Power Saving */ - pMciHw->HSMCI_CR = HSMCI_CR_MCIEN | HSMCI_CR_PWSEN ; - /* Configure MCI */ - pMciHw->HSMCI_CFG = HSMCI_CFG_FIFOMODE | ((1 << 4) & HSMCI_CFG_FERRCTRL); -#endif -} diff --git a/radio/bootloader/usbd_storage_msd.cpp b/radio/bootloader/usbd_storage_msd.cpp index 0f150a750..4aa3804d3 100644 --- a/radio/bootloader/usbd_storage_msd.cpp +++ b/radio/bootloader/usbd_storage_msd.cpp @@ -33,10 +33,13 @@ //#include #include "drivers.h" #include "../src/targets/taranis/i2c.h" - #include "diskio.h" //#include "board_taranis.h" +#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_gpio.h" +#include "hal.h" +#define SD_CARD_PRESENT() (~SD_PRESENT_GPIO->IDR & SD_PRESENT_GPIO_Pin) + void I2C_EE_BufferWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite) ; void eeprom_read_block (void *pointer_ram, uint16_t pointer_eeprom, size_t size); @@ -156,7 +159,7 @@ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_si *block_num = EESIZE/BLOCKSIZE + 3 + 1024 ; } else { - if (socket_is_empty()) + if (!SD_CARD_PRESENT()) return -1; *block_size = BLOCKSIZE; @@ -186,7 +189,7 @@ int8_t STORAGE_IsReady (uint8_t lun) return 0; } else { - return !socket_is_empty() ? 0 : -1; + return SD_CARD_PRESENT() ? 0 : -1; } } diff --git a/radio/src/targets/taranis/board_taranis.h b/radio/src/targets/taranis/board_taranis.h index 64e437b12..f561e979d 100644 --- a/radio/src/targets/taranis/board_taranis.h +++ b/radio/src/targets/taranis/board_taranis.h @@ -37,6 +37,10 @@ #ifndef board_taranis_h #define board_taranis_h +#ifdef __cplusplus +extern "C" { +#endif + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_rcc.h" #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_gpio.h" #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_spi.h" @@ -45,11 +49,6 @@ #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_dma.h" #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_usart.h" #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h" - -#ifdef __cplusplus -extern "C" { -#endif - #include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/inc/usbd_msc_core.h" #include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_usr.h" #include "usbd_desc.h" @@ -86,7 +85,7 @@ extern uint16_t sessionTimer; #define SLAVE_MODE() (g_model.trainerMode == 1) #define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(GPIOTRNDET, PIN_TRNDET) == Bit_RESET) -void delaysInit(); +void delaysInit(void); #define DEBUG_BAUDRATE 115200 #define SPORT_BAUDRATE 57600 diff --git a/radio/src/targets/taranis/diskio.cpp b/radio/src/targets/taranis/diskio.cpp index d9586804f..9d7a24b11 100644 --- a/radio/src/targets/taranis/diskio.cpp +++ b/radio/src/targets/taranis/diskio.cpp @@ -35,9 +35,10 @@ */ #include -#include "../FatFs/diskio.h" -#include "../FatFs/ff.h" -#include "../CoOS/kernel/CoOS.h" +#include "board_taranis.h" +#include "../../FatFs/diskio.h" +#include "../../FatFs/ff.h" +#include "../../CoOS/kernel/CoOS.h" #include "hal.h" /* Definitions for MMC/SDC command */ @@ -93,6 +94,7 @@ uint32_t transSpeed; */ /*-----------------------------------------------------------------------*/ /* Lock / unlock functions */ /*-----------------------------------------------------------------------*/ +#if !defined(BOOT) int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex) { *mutex = CoCreateMutex(); @@ -114,6 +116,7 @@ int ff_del_syncobj (_SYNC_t mutex) { return 1; } +#endif static const DWORD socket_state_mask_cp = (1 << 0); static const DWORD socket_state_mask_wp = (1 << 1); @@ -124,7 +127,6 @@ DSTATUS Stat = STA_NOINIT; /* Disk status */ static volatile DWORD Timer1, Timer2; /* 100Hz decrement timers */ -static BYTE CardType; /* Card type flags */ enum speed_setting { INTERFACE_SLOW, INTERFACE_FAST }; @@ -655,7 +657,6 @@ DSTATUS disk_initialize ( /*-----------------------------------------------------------------------*/ /* Get Disk Status */ /*-----------------------------------------------------------------------*/ - DSTATUS disk_status ( BYTE drv /* Physical drive number (0) */ ) @@ -665,7 +666,6 @@ DSTATUS disk_status ( } - /*-----------------------------------------------------------------------*/ /* Read Sector(s) */ /*-----------------------------------------------------------------------*/ @@ -966,7 +966,14 @@ FATFS g_FATFS_Obj; FIL g_telemetryFile = {0}; #endif -void sdInit() +#if defined(BOOT) +void sdInit(void) +{ + f_mount(0, &g_FATFS_Obj); +} +#else +// TODO shouldn't be there! +void sdInit(void) { if (f_mount(0, &g_FATFS_Obj) == FR_OK) { referenceSystemAudioFiles(); @@ -989,6 +996,7 @@ void sdDone() f_mount(0, 0); // unmount SD } } +#endif uint32_t sdMounted() { diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index f559ae171..592feb2c7 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -307,7 +307,9 @@ #define STM32_SD_DISK_IOCTRL_FORCE 0 //DMA -#define STM32_SD_USE_DMA //Enable the DMA for SD +#if !defined(BOOT) +#define STM32_SD_USE_DMA //Enable the DMA for SD +#endif #ifdef STM32_SD_USE_DMA #define DMA_Channel_SPI_SD_RX DMA1_Stream3