Merge remote-tracking branch 'origin/next' into bsongis/9XR-PRO_port
Conflicts: companion/src/eeprominterface.cpp companion/src/eeprominterface.h companion/src/firmwares/opentx/opentxeeprom.cpp companion/src/firmwares/opentx/opentxinterface.cpp companion/src/firmwares/opentx/opentxinterface.h companion/src/mdichild.cpp radio/src/Makefile
This commit is contained in:
@@ -186,6 +186,8 @@ void pwrOff();
|
||||
|
||||
// Haptic driver
|
||||
#define hapticOff() // TODO hapticOn() cleaner ...
|
||||
#define HAPTIC_ON() PORTD &= ~(1 << OUT_D_HAPTIC)
|
||||
#define HAPTIC_OFF() PORTD |= (1 << OUT_D_HAPTIC)
|
||||
|
||||
// Rotary encoder driver
|
||||
#if ROTARY_ENCODERS <= 2
|
||||
|
||||
@@ -47,7 +47,10 @@ extern bool isPlaying();
|
||||
#define PUSH_NUMBER_PROMPT(p) pushPrompt(PROMPT_I18N_BASE+(p))
|
||||
#define PUSH_SYSTEM_PROMPT(p) pushPrompt(PROMPT_SYSTEM_BASE+(p))
|
||||
#define PLAY_NUMBER(n, u, a) playNumber((n), (u), (a))
|
||||
#define PLAY_DURATION(d) playDuration((d))
|
||||
#define PLAY_DURATION(d, att) playDuration((d))
|
||||
#define PLAY_DURATION_ATT
|
||||
#define PLAY_TIME
|
||||
#define IS_PLAY_TIME() (0)
|
||||
#define IS_PLAYING(id) isPlaying()
|
||||
#define PLAY_VALUE(v, id) playValue((v))
|
||||
|
||||
|
||||
@@ -189,5 +189,7 @@ void pwrOff();
|
||||
|
||||
// Haptic driver
|
||||
#define hapticOff() // TODO hapticOn() cleaner ...
|
||||
#define HAPTIC_ON() PORTD &= ~(1 << OUT_D_HAPTIC)
|
||||
#define HAPTIC_OFF() PORTD |= (1 << OUT_D_HAPTIC)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
volatile uint16_t Analog_values[NUMBER_ANALOG];
|
||||
|
||||
#if defined(TARANIS_STICKS)
|
||||
#if defined(FRSKY_STICKS)
|
||||
const char ana_direction[NUMBER_ANALOG] = {1, 1, 0, 1 ,0 ,1 ,0, 0, 0};
|
||||
#endif
|
||||
|
||||
@@ -118,12 +118,12 @@ void adcRead()
|
||||
}
|
||||
|
||||
// adc direction correct
|
||||
#if defined(TARANIS_STICKS)
|
||||
#if defined(FRSKY_STICKS)
|
||||
uint32_t i ;
|
||||
for (i=0; i<NUMBER_ANALOG; i++) {
|
||||
if (ana_direction[i]) {
|
||||
Analog_values[i] = 4096-Analog_values[i];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ extern "C" void DAC_IRQHandler()
|
||||
{
|
||||
AudioBuffer *nextBuffer = audioQueue.getNextFilledBuffer();
|
||||
if (nextBuffer) {
|
||||
DACC->DACC_TNPR = CONVERT_PTR(nextBuffer->data);
|
||||
DACC->DACC_TNPR = CONVERT_PTR_UINT(nextBuffer->data);
|
||||
DACC->DACC_TNCR = nextBuffer->size/2;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -314,15 +314,14 @@ extern "C" void TC3_IRQHandler() //capture ppm in at 2MHz
|
||||
ppmInState = 1; // triggered
|
||||
}
|
||||
else {
|
||||
if (ppmInState && ppmInState<=16)
|
||||
{
|
||||
if (val>800 && val<2200) // if valid pulse-width range
|
||||
{
|
||||
g_ppmIns[ppmInState++ - 1] =
|
||||
(int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
||||
if (ppmInState>0 && ppmInState<=16) {
|
||||
if (val>800 && val<2200) { // if valid pulse-width range
|
||||
ppmInValid = 100;
|
||||
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
||||
}
|
||||
else
|
||||
else {
|
||||
ppmInState = 0; // not triggered
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,10 @@
|
||||
|
||||
extern uint16_t ResetReason;
|
||||
|
||||
#define BOOTLOADER_SIZE 0x8000
|
||||
#define FIRMWARE_SIZE (256*1024)
|
||||
#define FIRMWARE_ADDRESS 0x00400000
|
||||
|
||||
#if defined(REVA)
|
||||
#define GPIO_BUTTON_MENU PIOB->PIO_PDSR
|
||||
#define GPIO_BUTTON_EXIT PIOA->PIO_PDSR
|
||||
@@ -153,6 +157,10 @@ extern uint16_t sessionTimer;
|
||||
|
||||
void setSticksGain(uint8_t gains);
|
||||
|
||||
// Write Flash driver
|
||||
#define FLASH_PAGESIZE 256
|
||||
void writeFlash(uint32_t * address, uint32_t * buffer);
|
||||
|
||||
// Keys driver
|
||||
extern uint32_t readKeys();
|
||||
extern uint32_t readTrims();
|
||||
@@ -230,8 +238,9 @@ extern int8_t Coproc_temp;
|
||||
extern int8_t Coproc_maxtemp;
|
||||
|
||||
// Haptic driver
|
||||
void hapticOff(void) ;
|
||||
void hapticOff(void);
|
||||
void hapticOn(uint32_t pwmPercent);
|
||||
#define HAPTIC_OFF() hapticOff()
|
||||
|
||||
// BlueTooth driver
|
||||
#if defined(BLUETOOTH)
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
#include "../../opentx.h"
|
||||
|
||||
uint32_t (*IAP_Function)(uint32_t, uint32_t);
|
||||
|
||||
void writeFlash(uint32_t *address, uint32_t *buffer) // size is 256 bytes
|
||||
{
|
||||
uint32_t FlashSectorNum;
|
||||
uint32_t flash_cmd = 0;
|
||||
|
||||
// Always initialise this here, setting a default doesn't seem to work
|
||||
IAP_Function = (uint32_t (*)(uint32_t, uint32_t)) *(( uint32_t *)0x00800008);
|
||||
FlashSectorNum = (uint32_t) address;
|
||||
FlashSectorNum >>= 8;// page size is 256 bytes
|
||||
FlashSectorNum &= 2047;// max page number
|
||||
|
||||
/* Send data to the sector here */
|
||||
for (int i=0; i<FLASH_PAGESIZE/4; i++) {
|
||||
*address++ = *buffer++;
|
||||
}
|
||||
|
||||
/* build the command to send to EEFC */
|
||||
flash_cmd = (0x5A << 24) | (FlashSectorNum << 8) | 0x03; //AT91C_MC_FCMD_EWP ;
|
||||
|
||||
__disable_irq();
|
||||
/* Call the IAP function with appropriate command */
|
||||
i = IAP_Function(0, flash_cmd);
|
||||
__enable_irq();
|
||||
}
|
||||
|
||||
uint32_t readLockBits()
|
||||
{
|
||||
// Always initialise this here, setting a default doesn't seem to work
|
||||
IAP_Function = (uint32_t (*)(uint32_t, uint32_t)) *(( uint32_t *)0x00800008);
|
||||
|
||||
uint32_t flash_cmd = (0x5A << 24) | 0x0A;//AT91C_MC_FCMD_GLB ;
|
||||
__disable_irq();
|
||||
(void) IAP_Function( 0, flash_cmd );
|
||||
__enable_irq();
|
||||
return EFC->EEFC_FRR;
|
||||
}
|
||||
|
||||
void clearLockBits()
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t flash_cmd = 0;
|
||||
|
||||
// Always initialise this here, setting a default doesn't seem to work
|
||||
IAP_Function = (uint32_t (*)(uint32_t, uint32_t)) *(( uint32_t *)0x00800008);
|
||||
for ( i = 0; i < 16; i += 1 )
|
||||
{
|
||||
flash_cmd = (0x5A << 24) | ((128*i) << 8) | 0x09; //AT91C_MC_FCMD_CLB ;
|
||||
__disable_irq();
|
||||
/* Call the IAP function with appropriate command */
|
||||
(void) IAP_Function( 0, flash_cmd );
|
||||
__enable_irq();
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t isFirmwareStart(const void * buffer)
|
||||
{
|
||||
const uint32_t * block = (const uint32_t *)buffer;
|
||||
|
||||
if ((block[0] & 0xFFFE3000) != 0x20000000 ) {
|
||||
return 0;
|
||||
}
|
||||
if ((block[1] & 0xFFF80000) != 0x00400000) {
|
||||
return 0;
|
||||
}
|
||||
if ((block[2] & 0xFFF80000) != 0x00400000) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ extern "C" void PWM_IRQHandler(void)
|
||||
else {
|
||||
// Kick off serial output here
|
||||
sscptr = SSC;
|
||||
sscptr->SSC_TPR = CONVERT_PTR(pxxStream[0]);
|
||||
sscptr->SSC_TPR = CONVERT_PTR_UINT(pxxStream[0]);
|
||||
sscptr->SSC_TCR = (uint8_t *)pxxStreamPtr[0] - (uint8_t *)pxxStream[0];
|
||||
sscptr->SSC_PTCR = SSC_PTCR_TXTEN; // Start transfers
|
||||
}
|
||||
@@ -191,7 +191,7 @@ extern "C" void PWM_IRQHandler(void)
|
||||
else {
|
||||
// Kick off serial output here
|
||||
sscptr = SSC;
|
||||
sscptr->SSC_TPR = CONVERT_PTR(dsm2Stream);
|
||||
sscptr->SSC_TPR = CONVERT_PTR_UINT(dsm2Stream);
|
||||
sscptr->SSC_TCR = (uint8_t *)dsm2StreamPtr - (uint8_t *)dsm2Stream;
|
||||
sscptr->SSC_PTCR = SSC_PTCR_TXTEN; // Start transfers
|
||||
}
|
||||
|
||||
@@ -71,9 +71,15 @@ SECTIONS
|
||||
*/
|
||||
.text :
|
||||
{
|
||||
_stext = .; /* Provide the name for the start of this section */
|
||||
FILL(0xFFFF)
|
||||
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
|
||||
*(.bootrodata)
|
||||
*(.bootrodata.*)
|
||||
|
||||
. = ALIGN(32768); /* Align the start of the exidx part */
|
||||
_stext = .; /* Provide the name for the start of this section */
|
||||
KEEP(*(.vectors))
|
||||
|
||||
*(.text)
|
||||
@@ -129,11 +135,8 @@ SECTIONS
|
||||
|
||||
. = ALIGN(4); /* Align the end of the section */
|
||||
} > RAM
|
||||
_ebss = .; /* Provide the name for the end of this section */
|
||||
_ebss = .; /* Provide the name for the end of this section */
|
||||
|
||||
. = ALIGN(4); /* Align the end of the section */
|
||||
__end = .;
|
||||
_end = .;
|
||||
|
||||
/*
|
||||
* The ".stack" section is our stack.
|
||||
|
||||
@@ -54,7 +54,7 @@ static SBCInquiryData inquiryData = {
|
||||
SBC_PERIPHERAL_DEVICE_CONNECTED,// Peripheral device is connected
|
||||
0x00, // Reserved bits
|
||||
0x01, // Media is removable
|
||||
SBC_SPC_VERSION_4, // SPC-4 supported
|
||||
0x02, // SBC_SPC_VERSION_4, // SPC-4 supported
|
||||
0x2, // Response data format, must be 0x2
|
||||
0, // Hierarchical addressing not supported
|
||||
0, // ACA not supported
|
||||
|
||||
@@ -94,6 +94,8 @@
|
||||
#define SBC_VERIFY_10 0x2F
|
||||
/// Request a list of the possible capacities that can be formatted on medium
|
||||
#define SBC_READ_FORMAT_CAPACITIES 0x23
|
||||
|
||||
#define SBC_START_STOP 0x19
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -620,6 +622,21 @@ typedef struct {
|
||||
|
||||
} __attribute__ ((packed)) SBCReadWriteErrorRecovery; // GCC
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \brief start/stop command
|
||||
/// \see
|
||||
//------------------------------------------------------------------------------
|
||||
typedef struct {
|
||||
|
||||
unsigned char bModeDataLength; //!< Length of mode data to follow
|
||||
unsigned char bImmediate:1, //!<
|
||||
bReserved1:7; //!< Reserved bits
|
||||
unsigned char pReserved[2]; //!< Reserved bytes
|
||||
unsigned char startStop:1, //!< DPO/FUA bits supported ?
|
||||
eject:1, //!< Reserved bits
|
||||
bReserved2:6; //!< Is medium write-protected ?
|
||||
} __attribute__ ((packed)) SBCStartStop; // GCC
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \brief Generic structure for holding information about SBC commands
|
||||
/// \see SBCInquiry
|
||||
@@ -642,6 +659,7 @@ typedef union {
|
||||
SBCWrite10 write10; //!< WRITE (10) command
|
||||
SBCMediumRemoval mediumRemoval; //!< PREVENT/ALLOW MEDIUM REMOVAL command
|
||||
SBCModeSense6 modeSense6; //!< MODE SENSE (6) command
|
||||
SBCStartStop startStopCmd; //!< START-STOP command
|
||||
|
||||
} SBCCommand;
|
||||
|
||||
|
||||
@@ -1430,7 +1430,7 @@ unsigned char SBC_GetCommandInformation(void *command,
|
||||
|
||||
//------------------------------------
|
||||
case SBC_PREVENT_ALLOW_MEDIUM_REMOVAL:
|
||||
case 0x1B:
|
||||
case SBC_START_STOP:
|
||||
//------------------------------------
|
||||
(*type) = MSDD_NO_TRANSFER;
|
||||
break;
|
||||
@@ -1590,7 +1590,6 @@ unsigned char SBC_ProcessCommand(MSDLun *lun,
|
||||
|
||||
//------------------------------------
|
||||
case SBC_PREVENT_ALLOW_MEDIUM_REMOVAL:
|
||||
case 0x1B:
|
||||
//------------------------------------
|
||||
TRACE_INFO_WP("PrevAllowRem ");
|
||||
|
||||
@@ -1600,6 +1599,19 @@ unsigned char SBC_ProcessCommand(MSDLun *lun,
|
||||
result = MSDD_STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case SBC_START_STOP:
|
||||
TRACE_INFO_WP("StartStop ");
|
||||
|
||||
result = command->startStopCmd.startStop ;
|
||||
if (result == 0) {
|
||||
lun->status = LUN_EJECTED ;
|
||||
}
|
||||
else {
|
||||
lun->status = LUN_CHANGED ;
|
||||
}
|
||||
result = MSDD_STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
#if 0
|
||||
//------------------------------------
|
||||
case SBC_READ_FORMAT_CAPACITIES:
|
||||
|
||||
@@ -230,6 +230,10 @@ extern uint8_t RotEncoder ;
|
||||
void rotencPoll();
|
||||
#endif
|
||||
|
||||
// Haptic
|
||||
#define HAPTIC_ON() PORTG |= (1 << OUT_G_HAPTIC)
|
||||
#define HAPTIC_OFF() PORTG &= ~(1 << OUT_G_HAPTIC)
|
||||
|
||||
// USB fake driver
|
||||
#define usbPlugged() false
|
||||
|
||||
|
||||
@@ -134,6 +134,9 @@ inline bool isPlaying()
|
||||
#define PUSH_NUMBER_PROMPT(p) pushNumberPrompt((p))
|
||||
#define PUSH_SYSTEM_PROMPT(p) pushNumberPrompt(PROMPT_SYSTEM_BASE-PROMPT_I18N_BASE+(p))
|
||||
#define PLAY_NUMBER(n, u, a) playNumber((n), (u), (a))
|
||||
#define PLAY_DURATION(d) playDuration((d))
|
||||
#define PLAY_DURATION(d, att) playDuration((d))
|
||||
#define PLAY_DURATION_ATT
|
||||
#define PLAY_TIME
|
||||
#define IS_PLAY_TIME() (0)
|
||||
#define IS_PLAYING(id) (0) /* isPlaying() */
|
||||
#define PLAY_VALUE(v, id) playValue((v))
|
||||
|
||||
+2
-1
@@ -232,7 +232,8 @@ void SystemInit(void)
|
||||
#ifdef VECT_TAB_SRAM
|
||||
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
|
||||
#else
|
||||
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
|
||||
extern uint32_t g_pfnVectors ;
|
||||
SCB->VTOR = (uint32_t) &g_pfnVectors ; /* Vector Table Relocation in Internal FLASH */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -113,8 +113,8 @@
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f2xx_spi.h"
|
||||
#include "stm32f2xx_rcc.h"
|
||||
#include "../inc/stm32f2xx_spi.h"
|
||||
#include "../inc/stm32f2xx_rcc.h"
|
||||
|
||||
/** @addtogroup STM32F2xx_StdPeriph_Driver
|
||||
* @{
|
||||
|
||||
+23
-1
@@ -97,6 +97,7 @@ static int8_t SCSI_ReadFormatCapacity(uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_ReadCapacity10(uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_RequestSense (uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_StartStopUnit(uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_AllowRemoval(uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_ModeSense6 (uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_ModeSense10 (uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_Write10(uint8_t lun , uint8_t *params);
|
||||
@@ -146,7 +147,7 @@ int8_t SCSI_ProcessCmd(USB_OTG_CORE_HANDLE *pdev,
|
||||
return SCSI_StartStopUnit(lun, params);
|
||||
|
||||
case SCSI_ALLOW_MEDIUM_REMOVAL:
|
||||
return SCSI_StartStopUnit(lun, params);
|
||||
return SCSI_AllowRemoval( lun, params);
|
||||
|
||||
case SCSI_MODE_SENSE6:
|
||||
return SCSI_ModeSense6 (lun, params);
|
||||
@@ -432,7 +433,28 @@ void SCSI_SenseCode(uint8_t lun, uint8_t sKey, uint8_t ASC)
|
||||
* @param params: Command parameters
|
||||
* @retval status
|
||||
*/
|
||||
|
||||
extern uint8_t lunReady[] ;
|
||||
|
||||
static int8_t SCSI_StartStopUnit(uint8_t lun, uint8_t *params)
|
||||
{
|
||||
MSC_BOT_DataLen = 0;
|
||||
|
||||
if (lun < 2) {
|
||||
if (params[4] & 1) {
|
||||
// lun to be active
|
||||
lunReady[lun] = 1 ;
|
||||
}
|
||||
else {
|
||||
// lun to be ejected
|
||||
lunReady[lun] = 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int8_t SCSI_AllowRemoval(uint8_t lun, uint8_t *params)
|
||||
{
|
||||
MSC_BOT_DataLen = 0;
|
||||
return 0;
|
||||
|
||||
+8
-3
@@ -153,20 +153,25 @@ void USBD_Init(USB_OTG_CORE_HANDLE *pdev,
|
||||
/* Upon Init call usr callback */
|
||||
pdev->dev.usr_cb->Init();
|
||||
|
||||
/* Force Device Mode*/
|
||||
USB_OTG_SetCurrentMode(pdev, DEVICE_MODE);
|
||||
|
||||
/* Enable Interrupts */
|
||||
USB_OTG_BSP_EnableInterrupt(pdev);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_DeInit
|
||||
* Re-Initialize th device library
|
||||
* Deinitialize USB device library
|
||||
* @param pdev: device instance
|
||||
* @retval status: status
|
||||
*/
|
||||
USBD_Status USBD_DeInit(USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
/* Software Init */
|
||||
|
||||
/*Disable Interrupts*/
|
||||
USB_OTG_BSP_DisableInterrupt(pdev);
|
||||
USB_OTG_DisableGlobalInt(pdev);
|
||||
USB_OTG_BSP_Deinit(pdev);
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -78,9 +78,11 @@
|
||||
void BSP_Init(void);
|
||||
|
||||
void USB_OTG_BSP_Init (USB_OTG_CORE_HANDLE *pdev);
|
||||
void USB_OTG_BSP_Deinit(USB_OTG_CORE_HANDLE *pdev);
|
||||
void USB_OTG_BSP_uDelay (const uint32_t usec);
|
||||
void USB_OTG_BSP_mDelay (const uint32_t msec);
|
||||
void USB_OTG_BSP_EnableInterrupt (USB_OTG_CORE_HANDLE *pdev);
|
||||
void USB_OTG_BSP_DisableInterrupt (USB_OTG_CORE_HANDLE *pdev);
|
||||
#ifdef USE_HOST_MODE
|
||||
void USB_OTG_BSP_ConfigVBUS(USB_OTG_CORE_HANDLE *pdev);
|
||||
void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE *pdev,uint8_t state);
|
||||
|
||||
+36
@@ -195,6 +195,12 @@ uint32_t USBD_OTG_EP1IN_ISR_Handler (USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
DCD_WriteEmptyTxFifo(pdev , 1);
|
||||
CLEAR_IN_EP_INTR(1, emptyintr);
|
||||
/*
|
||||
Notice: this probabbly needs the same fix as DCD_HandleInEP_ISR(), but
|
||||
leaving this out, we don't use this part of code
|
||||
fifoemptymsk = 0x1 << 1;
|
||||
USB_OTG_MODIFY_REG32(&pdev->regs.DREGS->DIEPEMPMSK, fifoemptymsk, 0);
|
||||
*/
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -470,6 +476,36 @@ static uint32_t DCD_HandleInEP_ISR(USB_OTG_CORE_HANDLE *pdev)
|
||||
}
|
||||
if (diepint.b.emptyintr)
|
||||
{
|
||||
/*===============ADDED SECTION ==============================*/
|
||||
/*
|
||||
This only applies to INTERRUPT transfer mode.
|
||||
|
||||
diepint.b.emptyintr interrupt can't be reset by writing 1 to
|
||||
DIEPINT register. According to reference manual, this bit
|
||||
is read-only.
|
||||
|
||||
The CLEAR_IN_EP_INTR(epnum, emptyintr) does not work!
|
||||
|
||||
The only way to stop this interrupt is to disable it using
|
||||
mask register DIEPEMPMSK.
|
||||
|
||||
Original code gets here, is unsuccessful at interrupt flag reset
|
||||
and when interrupt handler returns, another one is fired again,
|
||||
robbing CPU time, which is then spent only in interrupt handlers
|
||||
(this one and all other that have higher priority)
|
||||
|
||||
This only happens in HID mode (when interrupt in endpoint is
|
||||
used) and when host is not actively polling device (us) for
|
||||
update. This is situation on Linux when no program is using
|
||||
joystick. The kernel/joystick driver stops polling device.
|
||||
|
||||
*/
|
||||
if ( pdev->dev.in_ep[epnum].type == USB_OTG_EP_INT ) {
|
||||
|
||||
fifoemptymsk = 0x1 << epnum;
|
||||
USB_OTG_MODIFY_REG32(&pdev->regs.DREGS->DIEPEMPMSK, fifoemptymsk, 0);
|
||||
}
|
||||
/*===============END OF ADDED SECTION ==============================*/
|
||||
|
||||
DCD_WriteEmptyTxFifo(pdev , epnum);
|
||||
|
||||
|
||||
@@ -59,10 +59,11 @@
|
||||
#define SAMPTIME 2 // sample time = 15 cycles
|
||||
|
||||
volatile uint16_t Analog_values[NUMBER_ANALOG];
|
||||
|
||||
#if defined(REV4a)
|
||||
const char ana_direction[NUMBER_ANALOG] = {0,1,0,1, 1,1,0,1,0, 0};
|
||||
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,-1,0,-1,1, 1};
|
||||
#elif !defined(REV3)
|
||||
const char ana_direction[NUMBER_ANALOG] = {0,1,0,1, 1,0,0,1,0, 0};
|
||||
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,0,-1,1, 1};
|
||||
#endif
|
||||
|
||||
void adcInit()
|
||||
@@ -98,8 +99,8 @@ void adcInit()
|
||||
ADC->CCR = 0 ; //ADC_CCR_ADCPRE_0 ; // Clock div 2
|
||||
|
||||
DMA2_Stream0->CR = DMA_SxCR_PL | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC ;
|
||||
DMA2_Stream0->PAR = CONVERT_PTR(&ADC1->DR);
|
||||
DMA2_Stream0->M0AR = CONVERT_PTR(Analog_values);
|
||||
DMA2_Stream0->PAR = CONVERT_PTR_UINT(&ADC1->DR);
|
||||
DMA2_Stream0->M0AR = CONVERT_PTR_UINT(Analog_values);
|
||||
DMA2_Stream0->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
|
||||
}
|
||||
|
||||
@@ -110,7 +111,7 @@ void adcRead()
|
||||
DMA2_Stream0->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
ADC1->SR &= ~(uint32_t) ( ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR ) ;
|
||||
DMA2->LIFCR = DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 |DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0 ; // Write ones to clear bits
|
||||
DMA2_Stream0->M0AR = CONVERT_PTR(Analog_values);
|
||||
DMA2_Stream0->M0AR = CONVERT_PTR_UINT(Analog_values);
|
||||
DMA2_Stream0->NDTR = NUMBER_ANALOG ;
|
||||
DMA2_Stream0->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
ADC1->CR2 |= (uint32_t)ADC_CR2_SWSTART ;
|
||||
@@ -124,9 +125,10 @@ void adcRead()
|
||||
#if !defined(REV3)
|
||||
// adc direction correct
|
||||
for (i=0; i<NUMBER_ANALOG; i++) {
|
||||
if (ana_direction[i]) {
|
||||
if (ana_direction[i] == -1)
|
||||
Analog_values[i] = 4096-Analog_values[i];
|
||||
}
|
||||
else if (ana_direction[i] == 0)
|
||||
Analog_values[i] = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "../opentx.h"
|
||||
#include "./STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_gpio.h"
|
||||
#include "board_taranis.h"
|
||||
|
||||
/**
|
||||
**********send command to lcd**************
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/spi/spi.h
|
||||
* @file Project/spi/spi.h
|
||||
* @author FrSky Application Team
|
||||
* @Hardware version V0.2
|
||||
* @date 11-July-2012
|
||||
@@ -11,27 +11,35 @@
|
||||
#ifndef _ASPI_H_
|
||||
#define _ASPI_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h"
|
||||
|
||||
#define __no_operation __NOP
|
||||
|
||||
#define LCD_NCS_HIGH() GPIO_LCD->BSRRL = PIN_LCD_NCS
|
||||
#define LCD_NCS_LOW() GPIO_LCD->BSRRH = PIN_LCD_NCS
|
||||
#define LCD_NCS_HIGH() GPIO_LCD_NCS->BSRRL = PIN_LCD_NCS
|
||||
#define LCD_NCS_LOW() GPIO_LCD_NCS->BSRRH = PIN_LCD_NCS
|
||||
|
||||
#define LCD_A0_HIGH() GPIO_LCD->BSRRL = PIN_LCD_A0
|
||||
#define LCD_A0_LOW() GPIO_LCD->BSRRH = PIN_LCD_A0
|
||||
#define LCD_A0_HIGH() GPIO_LCD_SPI->BSRRL = PIN_LCD_A0
|
||||
#define LCD_A0_LOW() GPIO_LCD_SPI->BSRRH = PIN_LCD_A0
|
||||
|
||||
#define LCD_RST_HIGH() GPIO_LCD->BSRRL = PIN_LCD_RST
|
||||
#define LCD_RST_LOW() GPIO_LCD->BSRRH = PIN_LCD_RST
|
||||
#define LCD_RST_HIGH() GPIO_LCD_RST->BSRRL = PIN_LCD_RST
|
||||
#define LCD_RST_LOW() GPIO_LCD_RST->BSRRH = PIN_LCD_RST
|
||||
|
||||
#define LCD_CLK_HIGH() GPIO_LCD->BSRRL = PIN_LCD_CLK
|
||||
#define LCD_CLK_LOW() GPIO_LCD->BSRRH = PIN_LCD_CLK
|
||||
#define LCD_CLK_HIGH() GPIO_LCD_SPI->BSRRL = PIN_LCD_CLK
|
||||
#define LCD_CLK_LOW() GPIO_LCD_SPI->BSRRH = PIN_LCD_CLK
|
||||
|
||||
#define LCD_MOSI_HIGH() GPIO_LCD->BSRRL = PIN_LCD_MOSI
|
||||
#define LCD_MOSI_LOW() GPIO_LCD->BSRRH = PIN_LCD_MOSI
|
||||
#define LCD_MOSI_HIGH() GPIO_LCD_SPI->BSRRL = PIN_LCD_MOSI
|
||||
#define LCD_MOSI_LOW() GPIO_LCD_SPI->BSRRH = PIN_LCD_MOSI
|
||||
|
||||
void AspiCmd(u8 Command_Byte);
|
||||
void AspiData(u8 Para_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "../../opentx.h"
|
||||
|
||||
bool dacIdle = true;
|
||||
int dacIdle = 1;
|
||||
|
||||
void setSampleRate(uint32_t frequency)
|
||||
{
|
||||
@@ -78,8 +78,8 @@ void dacInit()
|
||||
DMA1->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
||||
DMA1_Stream5->CR = DMA_SxCR_CHSEL_0 | DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_2 | DMA_SxCR_PL_0 |
|
||||
DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_CIRC ;
|
||||
DMA1_Stream5->PAR = CONVERT_PTR(&DAC->DHR12R1);
|
||||
// DMA1_Stream5->M0AR = CONVERT_PTR(Sine_values);
|
||||
DMA1_Stream5->PAR = CONVERT_PTR_UINT(&DAC->DHR12R1);
|
||||
// DMA1_Stream5->M0AR = CONVERT_PTR_UINT(Sine_values);
|
||||
DMA1_Stream5->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
|
||||
// DMA1_Stream5->NDTR = 100 ;
|
||||
|
||||
@@ -96,10 +96,10 @@ void dacInit()
|
||||
bool dacQueue(AudioBuffer *buffer)
|
||||
{
|
||||
if (dacIdle) {
|
||||
dacIdle = false;
|
||||
dacIdle = 0;
|
||||
DMA1_Stream5->CR &= ~DMA_SxCR_EN ; // Disable DMA channel
|
||||
DMA1->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
||||
DMA1_Stream5->M0AR = CONVERT_PTR(buffer->data);
|
||||
DMA1_Stream5->M0AR = CONVERT_PTR_UINT(buffer->data);
|
||||
DMA1_Stream5->NDTR = buffer->size;
|
||||
DMA1_Stream5->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE ; // Enable DMA channel and interrupt
|
||||
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
|
||||
@@ -111,6 +111,20 @@ bool dacQueue(AudioBuffer *buffer)
|
||||
}
|
||||
}
|
||||
|
||||
void dacStart()
|
||||
{
|
||||
DMA1->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
||||
DMA1_Stream5->CR |= DMA_SxCR_CIRC | DMA_SxCR_EN ; // Enable DMA channel
|
||||
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
|
||||
DAC->CR |= DAC_CR_EN1 | DAC_CR_DMAEN1 ; // Enable DAC
|
||||
}
|
||||
|
||||
void dacStop()
|
||||
{
|
||||
DMA1_Stream5->CR &= ~DMA_SxCR_CIRC ;
|
||||
}
|
||||
|
||||
|
||||
// Sound routines
|
||||
void audioInit()
|
||||
{
|
||||
@@ -142,14 +156,14 @@ extern "C" void DMA1_Stream5_IRQHandler()
|
||||
|
||||
AudioBuffer *nextBuffer = audioQueue.getNextFilledBuffer();
|
||||
if (nextBuffer) {
|
||||
DMA1_Stream5->M0AR = CONVERT_PTR(nextBuffer->data);
|
||||
DMA1_Stream5->M0AR = CONVERT_PTR_UINT(nextBuffer->data);
|
||||
DMA1_Stream5->NDTR = nextBuffer->size;
|
||||
DMA1->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
||||
DMA1_Stream5->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE ; // Enable DMA channel
|
||||
DAC->SR = DAC_SR_DMAUDR1; // Write 1 to clear flag
|
||||
}
|
||||
else {
|
||||
dacIdle = true;
|
||||
dacIdle = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -37,25 +37,14 @@
|
||||
#ifndef audio_driver_h
|
||||
#define audio_driver_h
|
||||
|
||||
extern void audioInit( void ) ;
|
||||
extern void audioEnd( void ) ;
|
||||
void audioInit( void ) ;
|
||||
void audioEnd( void ) ;
|
||||
void dacStart();
|
||||
void dacStop();
|
||||
|
||||
extern void setSampleRate(uint32_t frequency);
|
||||
|
||||
extern bool dacIdle;
|
||||
|
||||
inline void dacStart()
|
||||
{
|
||||
DMA1->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
||||
DMA1_Stream5->CR |= DMA_SxCR_CIRC | DMA_SxCR_EN ; // Enable DMA channel
|
||||
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
|
||||
DAC->CR |= DAC_CR_EN1 | DAC_CR_DMAEN1 ; // Enable DAC
|
||||
}
|
||||
|
||||
inline void dacStop()
|
||||
{
|
||||
DMA1_Stream5->CR &= ~DMA_SxCR_CIRC ;
|
||||
}
|
||||
extern int dacIdle;
|
||||
|
||||
#define VOLUME_LEVEL_MAX 23
|
||||
#define VOLUME_LEVEL_DEF 12
|
||||
|
||||
@@ -44,22 +44,6 @@ extern "C" {
|
||||
|
||||
volatile uint32_t Tenms ; // TODO to remove everywhere / use a #define
|
||||
|
||||
#define PIN_MODE_MASK 0x0003
|
||||
#define PIN_INPUT 0x0000
|
||||
#define PIN_OUTPUT 0x0001
|
||||
#define PIN_PERIPHERAL 0x0002
|
||||
#define PIN_ANALOG 0x0003
|
||||
#define PIN_PULL_MASK 0x000C
|
||||
#define PIN_PULLUP 0x0004
|
||||
#define PIN_NO_PULLUP 0x0000
|
||||
#define PIN_PULLDOWN 0x0008
|
||||
#define PIN_NO_PULLDOWN 0x0000
|
||||
#define PIN_PERI_MASK 0x00F0
|
||||
#define PIN_PUSHPULL 0x0000
|
||||
#define PIN_ODRAIN 0x8000
|
||||
#define PIN_PORT_MASK 0x0700
|
||||
#define PIN_SPEED_MASK 0x6000
|
||||
|
||||
#if !defined(SIMU)
|
||||
void configure_pins( uint32_t pins, uint16_t config )
|
||||
{
|
||||
@@ -106,32 +90,6 @@ void configure_pins( uint32_t pins, uint16_t config )
|
||||
}
|
||||
#endif
|
||||
|
||||
bool usbPlugged(void)
|
||||
{
|
||||
return GPIO_ReadInputDataBit(GPIOA, PIN_FS_VBUS);
|
||||
}
|
||||
|
||||
#if !defined(SIMU)
|
||||
extern "C" {
|
||||
USB_OTG_CORE_HANDLE USB_OTG_dev;
|
||||
|
||||
void OTG_FS_IRQHandler(void)
|
||||
{
|
||||
USBD_OTG_ISR_Handler (&USB_OTG_dev);
|
||||
}
|
||||
}
|
||||
|
||||
void usbInit()
|
||||
{
|
||||
USB_OTG_BSP_Init(&USB_OTG_dev);
|
||||
}
|
||||
|
||||
void usbStart()
|
||||
{
|
||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb);
|
||||
}
|
||||
#endif
|
||||
|
||||
void watchdogInit(unsigned int duration)
|
||||
{
|
||||
IWDG->KR = 0x5555 ; // Unlock registers
|
||||
@@ -172,6 +130,10 @@ void interrupt5ms()
|
||||
|
||||
AUDIO_HEARTBEAT();
|
||||
|
||||
#if defined(HAPTIC)
|
||||
HAPTIC_HEARTBEAT();
|
||||
#endif
|
||||
|
||||
if ( ++pre_scale >= 2 ) {
|
||||
pre_scale = 0 ;
|
||||
per10ms();
|
||||
@@ -197,6 +159,10 @@ void boardInit()
|
||||
eepromInit();
|
||||
sportInit();
|
||||
usbInit();
|
||||
|
||||
#if defined(HAPTIC)
|
||||
hapticInit();
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG)
|
||||
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP|DBGMCU_TIM1_STOP|DBGMCU_TIM2_STOP|DBGMCU_TIM3_STOP|DBGMCU_TIM6_STOP|DBGMCU_TIM8_STOP|DBGMCU_TIM10_STOP|DBGMCU_TIM13_STOP|DBGMCU_TIM14_STOP, ENABLE);
|
||||
@@ -205,4 +171,16 @@ void boardInit()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(REVPLUS)
|
||||
void turnBacklightOn(uint8_t level, uint8_t color)
|
||||
{
|
||||
TIM4->CCR4 = (100-level)*color;
|
||||
TIM4->CCR2 = (100-level)*(100-color);
|
||||
}
|
||||
|
||||
void turnBacklightOff(void)
|
||||
{
|
||||
TIM4->CCR4 = 0;
|
||||
TIM4->CCR2 = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -37,6 +37,12 @@
|
||||
#ifndef board_taranis_h
|
||||
#define board_taranis_h
|
||||
|
||||
#include "stddef.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,26 +51,56 @@
|
||||
#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"
|
||||
extern "C" {
|
||||
#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"
|
||||
#include "usb_conf.h"
|
||||
#include "usbd_conf.h"
|
||||
}
|
||||
|
||||
#if !defined(SIMU)
|
||||
#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/Class/hid/inc/usbd_hid_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"
|
||||
#include "usb_conf.h"
|
||||
#include "usbd_conf.h"
|
||||
#endif
|
||||
|
||||
#include "hal.h"
|
||||
#include "aspi.h"
|
||||
#include "i2c.h"
|
||||
#include "audio_driver.h"
|
||||
|
||||
#define PERI1_FREQUENCY 30000000
|
||||
#define PERI2_FREQUENCY 60000000
|
||||
#define TIMER_MULT_APB1 2
|
||||
#define TIMER_MULT_APB2 2
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOT)
|
||||
#include "audio_driver.h"
|
||||
#endif
|
||||
|
||||
#define FLASHSIZE 0x80000
|
||||
#define BOOTLOADER_SIZE 0x8000
|
||||
#define FIRMWARE_ADDRESS 0x08000000
|
||||
|
||||
#define PERI1_FREQUENCY 30000000
|
||||
#define PERI2_FREQUENCY 60000000
|
||||
#define TIMER_MULT_APB1 2
|
||||
#define TIMER_MULT_APB2 2
|
||||
|
||||
#define JACK_PPM_OUT()
|
||||
#define JACK_PPM_IN()
|
||||
|
||||
#define PIN_MODE_MASK 0x0003
|
||||
#define PIN_INPUT 0x0000
|
||||
#define PIN_OUTPUT 0x0001
|
||||
#define PIN_PERIPHERAL 0x0002
|
||||
#define PIN_ANALOG 0x0003
|
||||
#define PIN_PULL_MASK 0x000C
|
||||
#define PIN_PULLUP 0x0004
|
||||
#define PIN_NO_PULLUP 0x0000
|
||||
#define PIN_PULLDOWN 0x0008
|
||||
#define PIN_NO_PULLDOWN 0x0000
|
||||
#define PIN_PERI_MASK 0x00F0
|
||||
#define PIN_PUSHPULL 0x0000
|
||||
#define PIN_ODRAIN 0x8000
|
||||
#define PIN_PORT_MASK 0x0700
|
||||
#define PIN_SPEED_MASK 0x6000
|
||||
|
||||
void configure_pins( uint32_t pins, uint16_t config );
|
||||
|
||||
#define strcpy_P strcpy
|
||||
@@ -75,7 +111,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
|
||||
@@ -97,14 +133,22 @@ void delay_01us(uint16_t nb);
|
||||
#define SD_GET_SIZE_MB() (0)
|
||||
#define SD_GET_BLOCKNR() (0)
|
||||
#define SD_GET_SPEED() (0)
|
||||
void sdInit();
|
||||
void sdDone();
|
||||
void sdPoll10ms();
|
||||
void sdInit(void);
|
||||
void sdDone(void);
|
||||
void sdPoll10ms(void);
|
||||
#define sdMountPoll()
|
||||
uint32_t sdMounted();
|
||||
uint32_t sdMounted(void);
|
||||
#define SD_CARD_PRESENT() (~SD_PRESENT_GPIO->IDR & SD_PRESENT_GPIO_Pin)
|
||||
#endif
|
||||
|
||||
// Flash Write driver
|
||||
#define FLASH_PAGESIZE 256
|
||||
void unlockFlash(void);
|
||||
void lockFlash(void);
|
||||
void writeFlash(uint32_t * address, uint32_t * buffer);
|
||||
uint32_t isFirmwareStart(const void * buffer);
|
||||
uint32_t isBootloaderStart(const void * buffer);
|
||||
|
||||
// Pulses driver
|
||||
void init_no_pulses(uint32_t port);
|
||||
void disable_no_pulses(uint32_t port);
|
||||
@@ -116,15 +160,15 @@ void init_dsm2( uint32_t module_index );
|
||||
void disable_dsm2( uint32_t module_index );
|
||||
|
||||
// Trainer driver
|
||||
void init_trainer_ppm();
|
||||
void stop_trainer_ppm();
|
||||
void init_trainer_capture();
|
||||
void stop_trainer_capture();
|
||||
void init_trainer_ppm(void);
|
||||
void stop_trainer_ppm(void);
|
||||
void init_trainer_capture(void);
|
||||
void stop_trainer_capture(void);
|
||||
|
||||
// Keys driver
|
||||
void keysInit();
|
||||
uint32_t readKeys();
|
||||
uint32_t readTrims();
|
||||
void keysInit(void);
|
||||
uint32_t readKeys(void);
|
||||
uint32_t readTrims(void);
|
||||
#define TRIMS_PRESSED() (readTrims())
|
||||
#define KEYS_PRESSED() (~readKeys())
|
||||
#define DBLKEYS_PRESSED_RGT_LFT(i) ((in & ((2<<KEY_PLUS) + (2<<KEY_MINUS))) == ((2<<KEY_PLUS) + (2<<KEY_MINUS)))
|
||||
@@ -141,8 +185,8 @@ void watchdogInit(unsigned int duration);
|
||||
#endif
|
||||
|
||||
// ADC driver
|
||||
void adcInit();
|
||||
void adcRead();
|
||||
void adcInit(void);
|
||||
void adcRead(void);
|
||||
extern volatile uint16_t Analog_values[];
|
||||
#if defined(REV3)
|
||||
#define BATT_SCALE 120
|
||||
@@ -150,28 +194,46 @@ extern volatile uint16_t Analog_values[];
|
||||
#define BATT_SCALE 150
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Power driver
|
||||
void pwrInit();
|
||||
uint32_t pwrCheck();
|
||||
void pwrOff();
|
||||
void pwrInit(void);
|
||||
uint32_t pwrCheck(void);
|
||||
void pwrOff(void);
|
||||
#define UNEXPECTED_SHUTDOWN() (g_eeGeneral.unexpectedShutdown)
|
||||
#define INTERNAL_RF_ON() GPIO_SetBits(GPIOPWR, PIN_INT_RF_PWR)
|
||||
#define INTERNAL_RF_OFF() GPIO_ResetBits(GPIOPWR, PIN_INT_RF_PWR)
|
||||
#define EXTERNAL_RF_ON() GPIO_SetBits(GPIOPWR, PIN_EXT_RF_PWR)
|
||||
#define EXTERNAL_RF_OFF() GPIO_ResetBits(GPIOPWR, PIN_EXT_RF_PWR)
|
||||
#define INTERNAL_RF_ON() GPIO_SetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR)
|
||||
#define INTERNAL_RF_OFF() GPIO_ResetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR)
|
||||
#define EXTERNAL_RF_ON() GPIO_SetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR)
|
||||
#define EXTERNAL_RF_OFF() GPIO_ResetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR)
|
||||
|
||||
// Backlight driver
|
||||
#define setBacklight(xx) TIM10->CCR1 = 100-xx
|
||||
#define __BACKLIGHT_ON TIM10->CCR1 = 100-g_eeGeneral.backlightBright
|
||||
#define __BACKLIGHT_OFF TIM10->CCR1 = 0
|
||||
#define IS_BACKLIGHT_ON() (TIM10->CCR1 != 0)
|
||||
#if defined(REVPLUS)
|
||||
void turnBacklightOn(uint8_t level, uint8_t color);
|
||||
void turnBacklightOff(void);
|
||||
#define setBacklight(xx) turnBacklightOn(xx, g_eeGeneral.backlightColor)
|
||||
#define __BACKLIGHT_ON turnBacklightOn(g_eeGeneral.backlightBright, g_eeGeneral.backlightColor)
|
||||
#define __BACKLIGHT_OFF turnBacklightOff()
|
||||
#define IS_BACKLIGHT_ON() (TIM4->CCR4 != 0) || (TIM4->CCR2 != 0)
|
||||
#else
|
||||
#define setBacklight(xx) TIM10->CCR1 = 100-xx
|
||||
#define __BACKLIGHT_ON TIM10->CCR1 = 100-g_eeGeneral.backlightBright
|
||||
#define __BACKLIGHT_OFF TIM10->CCR1 = 0
|
||||
#define IS_BACKLIGHT_ON() (TIM10->CCR1 != 0)
|
||||
#endif
|
||||
|
||||
// USB driver
|
||||
#define BOOTLOADER_REQUEST() (0)
|
||||
#define usbBootloader()
|
||||
int usbPlugged(void);
|
||||
void usbInit(void);
|
||||
void usbStart(void);
|
||||
bool usbPlugged(void);
|
||||
void usbStop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// EEPROM driver
|
||||
#if !defined(SIMU)
|
||||
@@ -186,6 +248,17 @@ void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t si
|
||||
// Debug driver
|
||||
void debugPutc(const char c);
|
||||
|
||||
// Haptic driver
|
||||
void hapticInit(void);
|
||||
void hapticOff(void);
|
||||
#define HAPTIC_OFF() hapticOff()
|
||||
#if defined(REVPLUS)
|
||||
void hapticOn(uint32_t pwmPercent);
|
||||
#else
|
||||
void hapticOn();
|
||||
#define HAPTIC_ON() hapticOn()
|
||||
#endif
|
||||
|
||||
extern uint8_t currentTrainerMode;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../opentx.h"
|
||||
#include "board_taranis.h"
|
||||
|
||||
void delaysInit(void)
|
||||
{
|
||||
@@ -35,9 +35,10 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#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 };
|
||||
@@ -178,12 +180,10 @@ static void card_power(BYTE on)
|
||||
on=on;
|
||||
}
|
||||
|
||||
#if (STM32_SD_DISK_IOCTRL == 1)
|
||||
static int chk_power(void)
|
||||
{
|
||||
return 1; /* fake powered */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Transmit/Receive a byte to MMC via SPI (Platform dependent) */
|
||||
@@ -433,30 +433,29 @@ void power_on (void)
|
||||
static
|
||||
void power_off (void)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
if (!(Stat & STA_NOINIT)) {
|
||||
SELECT();
|
||||
wait_ready();
|
||||
release_spi();
|
||||
}
|
||||
if (!(Stat & STA_NOINIT)) {
|
||||
SELECT();
|
||||
wait_ready();
|
||||
release_spi();
|
||||
}
|
||||
|
||||
SPI_I2S_DeInit(SPI_SD);
|
||||
SPI_Cmd(SPI_SD, DISABLE);
|
||||
RCC_APBPeriphClockCmd_SPI_SD(RCC_APBPeriph_SPI_SD, DISABLE);
|
||||
|
||||
//All SPI-Pins to input with weak internal pull-downs
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SPI_SD_SCK | GPIO_Pin_SPI_SD_MISO | GPIO_Pin_SPI_SD_MOSI;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
SPI_I2S_DeInit(SPI_SD);
|
||||
SPI_Cmd(SPI_SD, DISABLE);
|
||||
RCC_APBPeriphClockCmd_SPI_SD(RCC_APBPeriph_SPI_SD, DISABLE);
|
||||
|
||||
//All SPI-Pins to input with weak internal pull-downs
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SPI_SD_SCK | GPIO_Pin_SPI_SD_MISO
|
||||
| GPIO_Pin_SPI_SD_MOSI;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
|
||||
GPIO_Init(GPIO_SPI_SD, &GPIO_InitStructure);
|
||||
GPIO_Init(GPIO_SPI_SD, &GPIO_InitStructure);
|
||||
|
||||
card_power(0);
|
||||
card_power(0);
|
||||
|
||||
Stat |= STA_NOINIT; /* Set STA_NOINIT */
|
||||
|
||||
Stat |= STA_NOINIT; /* Set STA_NOINIT */
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@@ -501,7 +500,6 @@ BOOL rcvr_datablock (
|
||||
/* Send a data packet to MMC */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if _FS_READONLY == 0
|
||||
static
|
||||
BOOL xmit_datablock (
|
||||
const BYTE *buff, /* 512 byte data block to be transmitted */
|
||||
@@ -537,8 +535,6 @@ BOOL xmit_datablock (
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* _READONLY */
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@@ -655,7 +651,6 @@ DSTATUS disk_initialize (
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Get Disk Status */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DSTATUS disk_status (
|
||||
BYTE drv /* Physical drive number (0) */
|
||||
)
|
||||
@@ -665,7 +660,6 @@ DSTATUS disk_status (
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Read Sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@@ -675,14 +669,23 @@ int8_t SD_ReadSectors(uint8_t *buff, uint32_t sector, uint32_t count)
|
||||
{
|
||||
if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */
|
||||
|
||||
if (send_cmd(CMD18, sector) == 0) { /* READ_MULTIPLE_BLOCK */
|
||||
do {
|
||||
if (!rcvr_datablock(buff, 512)) {
|
||||
break;
|
||||
if (count == 1) { /* Single block read */
|
||||
if (send_cmd(CMD17, sector) == 0) { /* READ_SINGLE_BLOCK */
|
||||
if (rcvr_datablock(buff, 512)) {
|
||||
count = 0;
|
||||
}
|
||||
buff += 512;
|
||||
} while (--count);
|
||||
send_cmd(CMD12, 0); /* STOP_TRANSMISSION */
|
||||
}
|
||||
}
|
||||
else { /* Multiple block read */
|
||||
if (send_cmd(CMD18, sector) == 0) { /* READ_MULTIPLE_BLOCK */
|
||||
do {
|
||||
if (!rcvr_datablock(buff, 512)) {
|
||||
break;
|
||||
}
|
||||
buff += 512;
|
||||
} while (--count);
|
||||
send_cmd(CMD12, 0); /* STOP_TRANSMISSION */
|
||||
}
|
||||
}
|
||||
|
||||
release_spi();
|
||||
@@ -700,29 +703,9 @@ DRESULT disk_read (
|
||||
if (drv || !count) return RES_PARERR;
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||
|
||||
if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */
|
||||
SD_ReadSectors(buff, sector, count);
|
||||
|
||||
if (count == 1) { /* Single block read */
|
||||
if (send_cmd(CMD17, sector) == 0) { /* READ_SINGLE_BLOCK */
|
||||
if (rcvr_datablock(buff, 512)) {
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else { /* Multiple block read */
|
||||
if (send_cmd(CMD18, sector) == 0) { /* READ_MULTIPLE_BLOCK */
|
||||
do {
|
||||
if (!rcvr_datablock(buff, 512)) {
|
||||
break;
|
||||
}
|
||||
buff += 512;
|
||||
} while (--count);
|
||||
send_cmd(CMD12, 0); /* STOP_TRANSMISSION */
|
||||
}
|
||||
}
|
||||
release_spi();
|
||||
|
||||
return count ? RES_ERROR : RES_OK;
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -731,8 +714,6 @@ DRESULT disk_read (
|
||||
/* Write Sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if _FS_READONLY == 0
|
||||
|
||||
// TODO quick & dirty
|
||||
int8_t SD_WriteSectors(uint8_t *buff, uint32_t sector, uint32_t count)
|
||||
{
|
||||
@@ -752,6 +733,8 @@ int8_t SD_WriteSectors(uint8_t *buff, uint32_t sector, uint32_t count)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if _FS_READONLY == 0
|
||||
|
||||
DRESULT disk_write (
|
||||
BYTE drv, /* Physical drive number (0) */
|
||||
const BYTE *buff, /* Pointer to the data to be written */
|
||||
@@ -793,7 +776,6 @@ DRESULT disk_write (
|
||||
/* Miscellaneous Functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if (STM32_SD_DISK_IOCTRL == 1)
|
||||
DRESULT disk_ioctl (
|
||||
BYTE drv, /* Physical drive number (0) */
|
||||
BYTE ctrl, /* Control code */
|
||||
@@ -919,7 +901,6 @@ DRESULT disk_ioctl (
|
||||
|
||||
return res;
|
||||
}
|
||||
#endif /* _USE_IOCTL != 0 */
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@@ -966,7 +947,16 @@ FATFS g_FATFS_Obj;
|
||||
FIL g_telemetryFile = {0};
|
||||
#endif
|
||||
|
||||
void sdInit()
|
||||
#if defined(BOOT)
|
||||
void sdInit(void)
|
||||
{
|
||||
if (f_mount(0, &g_FATFS_Obj) == FR_OK) {
|
||||
f_chdir("/");
|
||||
}
|
||||
}
|
||||
#else
|
||||
// TODO shouldn't be there!
|
||||
void sdInit(void)
|
||||
{
|
||||
if (f_mount(0, &g_FATFS_Obj) == FR_OK) {
|
||||
referenceSystemAudioFiles();
|
||||
@@ -989,6 +979,7 @@ void sdDone()
|
||||
f_mount(0, 0); // unmount SD
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t sdMounted()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
#include "../../opentx.h"
|
||||
#include "stm32f2xx_flash.h"
|
||||
|
||||
//After reset, write is not allowed in the Flash control register (FLASH_CR) to protect the
|
||||
//Flash memory against possible unwanted operations due, for example, to electric
|
||||
//disturbances. The following sequence is used to unlock this register:
|
||||
//1. Write KEY1 = 0x45670123 in the Flash key register (FLASH_KEYR)
|
||||
//2. Write KEY2 = 0xCDEF89AB in the Flash key register (FLASH_KEYR)
|
||||
//Any wrong sequence will return a bus error and lock up the FLASH_CR register until the
|
||||
//next reset.
|
||||
//The FLASH_CR register can be locked again by software by setting the LOCK bit in the
|
||||
//FLASH_CR register.
|
||||
void unlockFlash()
|
||||
{
|
||||
FLASH->KEYR = 0x45670123;
|
||||
FLASH->KEYR = 0xCDEF89AB;
|
||||
}
|
||||
|
||||
void lockFlash()
|
||||
{
|
||||
while (!FLASH->SR & FLASH_SR_BSY);
|
||||
FLASH->CR |= FLASH_CR_LOCK;
|
||||
}
|
||||
|
||||
void waitFlashIdle()
|
||||
{
|
||||
while (FLASH->SR & FLASH_FLAG_BSY) {
|
||||
wdt_reset();
|
||||
}
|
||||
}
|
||||
|
||||
#define SECTOR_MASK ((uint32_t)0xFFFFFF07)
|
||||
|
||||
void eraseSector(uint32_t sector)
|
||||
{
|
||||
waitFlashIdle();
|
||||
|
||||
FLASH->CR &= CR_PSIZE_MASK;
|
||||
FLASH->CR |= FLASH_PSIZE_WORD;
|
||||
FLASH->CR &= SECTOR_MASK;
|
||||
FLASH->CR |= FLASH_CR_SER | (sector << 3);
|
||||
FLASH->CR |= FLASH_CR_STRT;
|
||||
|
||||
/* Wait for operation to be completed */
|
||||
waitFlashIdle();
|
||||
|
||||
/* if the erase operation is completed, disable the SER Bit */
|
||||
FLASH->CR &= (~FLASH_CR_SER);
|
||||
FLASH->CR &= SECTOR_MASK;
|
||||
}
|
||||
|
||||
void writeFlash(uint32_t *address, uint32_t *buffer) // page size is 256 bytes
|
||||
{
|
||||
if ((uint32_t) address == 0x08000000) {
|
||||
eraseSector(0);
|
||||
}
|
||||
else if ((uint32_t) address == 0x08004000) {
|
||||
eraseSector(1);
|
||||
}
|
||||
else if ((uint32_t) address == 0x08008000) {
|
||||
eraseSector(2);
|
||||
}
|
||||
else if ((uint32_t) address == 0x0800C000) {
|
||||
eraseSector(3);
|
||||
}
|
||||
else if ((uint32_t) address == 0x08010000) {
|
||||
eraseSector(4);
|
||||
}
|
||||
else if ((uint32_t) address == 0x08020000) {
|
||||
eraseSector(5);
|
||||
}
|
||||
else if ((uint32_t) address == 0x08040000) {
|
||||
eraseSector(6);
|
||||
}
|
||||
else if ((uint32_t) address == 0x08060000) {
|
||||
eraseSector(7);
|
||||
}
|
||||
|
||||
for (uint32_t i=0; i<FLASH_PAGESIZE/4; i++) {
|
||||
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
|
||||
be done by word */
|
||||
|
||||
// Wait for last operation to be completed
|
||||
waitFlashIdle();
|
||||
|
||||
FLASH->CR &= CR_PSIZE_MASK;
|
||||
FLASH->CR |= FLASH_PSIZE_WORD;
|
||||
FLASH->CR |= FLASH_CR_PG;
|
||||
|
||||
*address = *buffer;
|
||||
|
||||
/* Wait for operation to be completed */
|
||||
waitFlashIdle();
|
||||
FLASH->CR &= (~FLASH_CR_PG);
|
||||
|
||||
/* Check the written value */
|
||||
if (*address != *buffer) {
|
||||
/* Flash content doesn't match SRAM content */
|
||||
return;
|
||||
}
|
||||
/* Increment FLASH destination address */
|
||||
address += 1;
|
||||
buffer += 1;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t isFirmwareStart(const void * buffer)
|
||||
{
|
||||
const uint32_t * block = (const uint32_t *)buffer;
|
||||
|
||||
if ((block[0] & 0xFFFC0000) != 0x20000000) {
|
||||
return 0;
|
||||
}
|
||||
if ((block[1] & 0xFFF00000) != 0x08000000) {
|
||||
return 0;
|
||||
}
|
||||
if ((block[2] & 0xFFF00000) != 0x08000000) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t isBootloaderStart(const void * buffer)
|
||||
{
|
||||
const uint32_t * block = (const uint32_t *)buffer;
|
||||
|
||||
for (int i=0; i<256; i++) {
|
||||
if (block[i] == 0x544F4F42/*BOOT*/) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
+101
-43
@@ -14,10 +14,10 @@
|
||||
#define GPIO_BUTTON_MENU GPIOD->IDR
|
||||
#define GPIO_BUTTON_EXIT GPIOD->IDR
|
||||
#define GPIO_BUTTON_PAGE GPIOD->IDR
|
||||
#define PIN_BUTTON_PLUS GPIO_Pin_10 //SW3 PE.10
|
||||
#define PIN_BUTTON_PLUS GPIO_Pin_10 //SW3 PE.10
|
||||
#define PIN_BUTTON_MINUS GPIO_Pin_11 //SW1 PE.12
|
||||
#define PIN_BUTTON_ENTER GPIO_Pin_12 //SW2 PE.11
|
||||
#define PIN_BUTTON_MENU GPIO_Pin_7 //SW4 PD.07
|
||||
#define PIN_BUTTON_ENTER GPIO_Pin_12 //SW2 PE.11
|
||||
#define PIN_BUTTON_MENU GPIO_Pin_7 //SW4 PD.07
|
||||
#define PIN_BUTTON_PAGE GPIO_Pin_3 //SW6 PD.02
|
||||
#define PIN_BUTTON_EXIT GPIO_Pin_2 //SW5 PD.03
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
#define GPIO_TRIM_LV_UP GPIOE->IDR
|
||||
#define GPIO_TRIM_RV_DN GPIOC->IDR
|
||||
#define GPIO_TRIM_RH_R GPIOC->IDR
|
||||
#define PIN_TRIM_RV_DN GPIO_Pin_3 //PC.03
|
||||
#define PIN_TRIM_RV_UP GPIO_Pin_2 //PC.02
|
||||
#define PIN_TRIM_RH_L GPIO_Pin_1 //PC.01
|
||||
#define PIN_TRIM_RH_R GPIO_Pin_13 //PC.13
|
||||
#define PIN_TRIM_RV_DN GPIO_Pin_3 //PC.03
|
||||
#define PIN_TRIM_RV_UP GPIO_Pin_2 //PC.02
|
||||
#define PIN_TRIM_RH_L GPIO_Pin_1 //PC.01
|
||||
#define PIN_TRIM_RH_R GPIO_Pin_13 //PC.13
|
||||
#if defined(REV3)
|
||||
#define PIN_TRIM_LH_R GPIO_Pin_4 //PE.04
|
||||
#define PIN_TRIM_LH_R GPIO_Pin_4 //PE.04
|
||||
#define PIN_TRIM_LH_L GPIO_Pin_3 //PE.03
|
||||
#else
|
||||
#define PIN_TRIM_LH_L GPIO_Pin_4 //PE.04
|
||||
@@ -47,7 +47,7 @@
|
||||
// Switchs
|
||||
#if defined(REV3)
|
||||
#define GPIO_PIN_SW_F (~GPIOE->IDR)
|
||||
#define PIN_SW_F GPIO_Pin_14 //PE.14
|
||||
#define PIN_SW_F GPIO_Pin_14 //PE.14
|
||||
#else
|
||||
#define GPIO_PIN_SW_F GPIOE->IDR
|
||||
#define PIN_SW_F GPIO_Pin_14 //PE.14
|
||||
@@ -55,8 +55,8 @@
|
||||
|
||||
#define GPIO_PIN_SW_E_L GPIOB->IDR
|
||||
#define GPIO_PIN_SW_E_H GPIOB->IDR
|
||||
#define PIN_SW_E_L GPIO_Pin_3 //PB.03
|
||||
#define PIN_SW_E_H GPIO_Pin_4 //PB.04
|
||||
#define PIN_SW_E_L GPIO_Pin_3 //PB.03
|
||||
#define PIN_SW_E_H GPIO_Pin_4 //PB.04
|
||||
|
||||
#if defined(REV3)
|
||||
#define GPIO_PIN_SW_B_L GPIOB->IDR
|
||||
@@ -73,8 +73,8 @@
|
||||
#if defined(REV3)
|
||||
#define GPIO_PIN_SW_A_H (~GPIOB->IDR)
|
||||
#define GPIO_PIN_SW_A_L (~GPIOE->IDR)
|
||||
#define PIN_SW_A_H GPIO_Pin_7 //PB.07
|
||||
#define PIN_SW_A_L GPIO_Pin_2 //PE.02
|
||||
#define PIN_SW_A_H GPIO_Pin_7 //PB.07
|
||||
#define PIN_SW_A_L GPIO_Pin_2 //PE.02
|
||||
#else
|
||||
#define GPIO_PIN_SW_A_H GPIOB->IDR
|
||||
#define GPIO_PIN_SW_A_L GPIOE->IDR
|
||||
@@ -86,7 +86,7 @@
|
||||
#define GPIO_PIN_SW_G_H (~GPIOA->IDR)
|
||||
#define GPIO_PIN_SW_G_L (~GPIOB->IDR)
|
||||
#define PIN_SW_G_H GPIO_Pin_5 //PA.05
|
||||
#define PIN_SW_G_L GPIO_Pin_0 //PB.00
|
||||
#define PIN_SW_G_L GPIO_Pin_0 //PB.00
|
||||
#else
|
||||
#define GPIO_PIN_SW_G_H GPIOE->IDR
|
||||
#define GPIO_PIN_SW_G_L GPIOE->IDR
|
||||
@@ -98,7 +98,7 @@
|
||||
#define GPIO_PIN_SW_C_H (~GPIOB->IDR)
|
||||
#define GPIO_PIN_SW_C_L (~GPIOE->IDR)
|
||||
#define PIN_SW_C_H GPIO_Pin_1 //PB.01
|
||||
#define PIN_SW_C_L GPIO_Pin_7 //PE.07
|
||||
#define PIN_SW_C_L GPIO_Pin_7 //PE.07
|
||||
#else
|
||||
#define GPIO_PIN_SW_C_H GPIOE->IDR
|
||||
#define GPIO_PIN_SW_C_L GPIOA->IDR
|
||||
@@ -109,8 +109,13 @@
|
||||
#if defined(REV3)
|
||||
#define GPIO_PIN_SW_D_H (~GPIOE->IDR)
|
||||
#define GPIO_PIN_SW_D_L (~GPIOE->IDR)
|
||||
#define PIN_SW_D_H GPIO_Pin_9 //PE.09
|
||||
#define PIN_SW_D_L GPIO_Pin_8 //PE.08
|
||||
#define PIN_SW_D_H GPIO_Pin_9 //PE.09
|
||||
#define PIN_SW_D_L GPIO_Pin_8 //PE.08
|
||||
#elif defined(REVPLUS)
|
||||
#define GPIO_PIN_SW_D_H (GPIOE->IDR)
|
||||
#define GPIO_PIN_SW_D_L (GPIOE->IDR)
|
||||
#define PIN_SW_D_H GPIO_Pin_7 //PE.07
|
||||
#define PIN_SW_D_L GPIO_Pin_13 //PE.13
|
||||
#else
|
||||
#define GPIO_PIN_SW_D_H GPIOE->IDR
|
||||
#define GPIO_PIN_SW_D_L GPIOB->IDR
|
||||
@@ -121,6 +126,9 @@
|
||||
#if defined(REV3)
|
||||
#define GPIO_PIN_SW_H (~GPIOE->IDR)
|
||||
#define PIN_SW_H GPIO_Pin_13 //PE.13
|
||||
#elif defined(REVPLUS)
|
||||
#define GPIO_PIN_SW_H GPIOD->IDR
|
||||
#define PIN_SW_H GPIO_Pin_14 //PD.14
|
||||
#else
|
||||
#define GPIO_PIN_SW_H GPIOE->IDR
|
||||
#define PIN_SW_H GPIO_Pin_13 //PE.13
|
||||
@@ -139,6 +147,9 @@
|
||||
#else
|
||||
#define PIN_FLP_J2 GPIO_Pin_0 //PB.00
|
||||
#endif
|
||||
#if defined(REVPLUS)
|
||||
#define PIN_FLP_J3 GPIO_Pin_1 //PB.01
|
||||
#endif
|
||||
#define PIN_MVOLT GPIO_Pin_0 //PC.00
|
||||
#if defined(REV3)
|
||||
#define RCC_AHB1Periph_GPIOADC RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC
|
||||
@@ -156,8 +167,15 @@
|
||||
#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 GPIO_EXT_RF_PWR GPIOD
|
||||
#define PIN_EXT_RF_PWR GPIO_Pin_8
|
||||
#if defined(REVPLUS)
|
||||
#define GPIO_INT_RF_PWR GPIOC
|
||||
#define PIN_INT_RF_PWR GPIO_Pin_6
|
||||
#else
|
||||
#define GPIO_INT_RF_PWR GPIOD
|
||||
#define PIN_INT_RF_PWR GPIO_Pin_15
|
||||
#endif
|
||||
|
||||
// Trainer Port
|
||||
#define GPIO_TR_INOUT GPIOC
|
||||
@@ -219,20 +237,46 @@
|
||||
#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
|
||||
// BackLight
|
||||
#if defined (REVPLUS)
|
||||
#define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOD
|
||||
#define GPIO_Pin_BL GPIO_Pin_15 //PD.15
|
||||
#define Pin_BL_AF GPIO_AF_TIM4
|
||||
#define GPIOBL GPIOD
|
||||
#define GPIO_PinSource_BL GPIO_PinSource15
|
||||
#define GPIO_Pin_BLW GPIO_Pin_13 //PD.13
|
||||
#define Pin_BLW_AF GPIO_AF_TIM4
|
||||
#define GPIO_PinSource_BLW GPIO_PinSource13
|
||||
#else
|
||||
#define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOB
|
||||
#define GPIO_Pin_BL GPIO_Pin_8 //PB.08
|
||||
#define Pin_BL_AF GPIO_AF_TIM10
|
||||
#define GPIOBL GPIOB
|
||||
#define GPIO_PinSource_BL GPIO_PinSource8
|
||||
#endif
|
||||
|
||||
// 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
|
||||
// LCD
|
||||
#if defined(REVPLUS)
|
||||
#define RCC_AHB1Periph_LCD RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD
|
||||
#define GPIO_LCD_SPI GPIOC
|
||||
#define GPIO_LCD_NCS GPIOA
|
||||
#define GPIO_LCD_RST GPIOD
|
||||
#define PIN_LCD_MOSI GPIO_Pin_12 //PC.12
|
||||
#define PIN_LCD_CLK GPIO_Pin_10 //PC.10
|
||||
#define PIN_LCD_NCS GPIO_Pin_15 //PA.15
|
||||
#define PIN_LCD_A0 GPIO_Pin_11 //PC.11
|
||||
#define PIN_LCD_RST GPIO_Pin_12 //PD.12
|
||||
#else
|
||||
#define RCC_AHB1Periph_LCD RCC_AHB1Periph_GPIOD
|
||||
#define GPIO_LCD_SPI GPIOD
|
||||
#define GPIO_LCD_NCS GPIOD
|
||||
#define GPIO_LCD_RST 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 //PD.12
|
||||
#endif
|
||||
|
||||
// Audio - I2S3
|
||||
#define CODEC_I2S SPI3
|
||||
@@ -296,27 +340,29 @@
|
||||
#define RCC_AHB1Periph_GPIO_SD RCC_AHB1Periph_GPIOB
|
||||
#define RCC_APBPeriphClockCmd_SPI_SD RCC_APB1PeriphClockCmd
|
||||
#define RCC_APBPeriph_SPI_SD RCC_APB1Periph_SPI2
|
||||
#define RCC_AHB1Periph_DMA_SD RCC_AHB1Periph_DMA1
|
||||
#define SPI_BaudRatePrescaler_SPI_SD SPI_BaudRatePrescaler_4 //10.5<20MHZ,make sure < 20MHZ
|
||||
#define RCC_AHB1Periph_DMA_SD RCC_AHB1Periph_DMA1
|
||||
#define SPI_BaudRatePrescaler_SPI_SD SPI_BaudRatePrescaler_4 //10.5<20MHZ,make sure < 20MHZ
|
||||
|
||||
//disabled io_ctl and cp/wp
|
||||
#define CARD_SUPPLY_SWITCHABLE 0
|
||||
#define SOCKET_WP_CONNECTED 0
|
||||
#define SOCKET_CP_CONNECTED 0
|
||||
#define CARD_SUPPLY_SWITCHABLE 0
|
||||
#define SOCKET_WP_CONNECTED 0
|
||||
#define SOCKET_CP_CONNECTED 0
|
||||
/* set to 1 to provide a disk_ioctrl function even if not needed by the FatFs */
|
||||
#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
|
||||
#define DMA_Channel_SPI_SD_TX DMA1_Stream4
|
||||
#define DMA_Channel_SPI_SD_RX DMA1_Stream3
|
||||
#define DMA_Channel_SPI_SD_TX DMA1_Stream4
|
||||
|
||||
#define DMA_FLAG_SPI_SD_TC_RX DMA_FLAG_TCIF3
|
||||
#define DMA_FLAG_SPI_SD_TC_TX DMA_FLAG_TCIF4
|
||||
#define DMA_Channel_SPI2_TX DMA_Channel_0
|
||||
#define DMA_Channel_SPI2_RX DMA_Channel_0
|
||||
#define DMA_FLAG_SPI_SD_TC_RX DMA_FLAG_TCIF3
|
||||
#define DMA_FLAG_SPI_SD_TC_TX DMA_FLAG_TCIF4
|
||||
#define DMA_Channel_SPI2_TX DMA_Channel_0
|
||||
#define DMA_Channel_SPI2_RX DMA_Channel_0
|
||||
#endif
|
||||
|
||||
// Audio----I2S3-----SPI3
|
||||
@@ -331,4 +377,16 @@
|
||||
#define I2C_EEPROM_ADDRESS 0xA2
|
||||
#define I2C_CAT5137_ADDRESS 0x5C //0101110
|
||||
|
||||
// Haptic
|
||||
#if defined(REVPLUS)
|
||||
#define RCC_AHB1Periph_GPIOHAPTIC RCC_AHB1Periph_GPIOB
|
||||
#define GPIO_PinSource_HAPTIC GPIO_PinSource8
|
||||
#define GPIO_HAPTIC GPIOB
|
||||
#define PIN_HAPTIC GPIO_Pin_8
|
||||
#else
|
||||
#define RCC_AHB1Periph_GPIOHAPTIC RCC_AHB1Periph_GPIOC
|
||||
#define GPIO_HAPTIC GPIOC
|
||||
#define PIN_HAPTIC GPIO_Pin_12
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
*
|
||||
* opentx 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 "../../opentx.h"
|
||||
|
||||
#if defined(REVPLUS)
|
||||
void hapticOff(void)
|
||||
{
|
||||
TIM10->CCR1 = 0;
|
||||
}
|
||||
|
||||
void hapticOn(uint32_t pwmPercent)
|
||||
{
|
||||
if (pwmPercent > 100) {
|
||||
pwmPercent = 100;
|
||||
}
|
||||
TIM10->CCR1 = pwmPercent;
|
||||
}
|
||||
|
||||
void hapticInit(void)
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOHAPTIC, ENABLE);
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_HAPTIC;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_HAPTIC, &GPIO_InitStructure);
|
||||
|
||||
GPIO_PinAFConfig(GPIO_HAPTIC, GPIO_PinSource_HAPTIC, GPIO_AF_TIM10);
|
||||
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM10EN ; // Enable clock
|
||||
TIM10->ARR = 100 ;
|
||||
TIM10->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1;
|
||||
TIM10->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 ; // PWM
|
||||
TIM10->CCER = TIM_CCER_CC1E ;
|
||||
|
||||
TIM10->CCR1 = 0 ;
|
||||
TIM10->EGR = 0 ;
|
||||
TIM10->CR1 = TIM_CR1_CEN ; // Counter enable
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// No PWM before REVPLUS
|
||||
void hapticInit(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOHAPTIC, ENABLE);
|
||||
|
||||
/* GPIO Configuration*/
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_HAPTIC;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_HAPTIC, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
void hapticOff(void)
|
||||
{
|
||||
GPIO_ResetBits(GPIO_HAPTIC, PIN_HAPTIC);
|
||||
}
|
||||
|
||||
void hapticOn()
|
||||
{
|
||||
GPIO_SetBits(GPIO_HAPTIC, PIN_HAPTIC);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "../opentx.h"
|
||||
#include "board_taranis.h"
|
||||
|
||||
#define I2C_delay() delay_01us(100);
|
||||
|
||||
@@ -44,7 +44,7 @@ static void I2C_GPIO_Configuration(void)
|
||||
SCL_H;
|
||||
}
|
||||
|
||||
short I2C_START()
|
||||
short I2C_START(void)
|
||||
{
|
||||
SDA_H;
|
||||
I2C_delay();
|
||||
@@ -59,7 +59,7 @@ short I2C_START()
|
||||
return 1;
|
||||
}
|
||||
|
||||
void I2C_STOP()
|
||||
void I2C_STOP(void)
|
||||
{
|
||||
SCL_L;
|
||||
I2C_delay();
|
||||
@@ -71,7 +71,7 @@ void I2C_STOP()
|
||||
I2C_delay();
|
||||
}
|
||||
|
||||
void I2C_ACK()
|
||||
void I2C_ACK(void)
|
||||
{
|
||||
SCL_L;
|
||||
I2C_delay();
|
||||
@@ -82,7 +82,8 @@ void I2C_ACK()
|
||||
SCL_L;
|
||||
I2C_delay();
|
||||
}
|
||||
void I2C_NO_ACK()
|
||||
|
||||
void I2C_NO_ACK(void)
|
||||
{
|
||||
SCL_L;
|
||||
I2C_delay();
|
||||
@@ -94,7 +95,7 @@ void I2C_NO_ACK()
|
||||
I2C_delay();
|
||||
}
|
||||
|
||||
short I2C_WAIT_ACK()
|
||||
short I2C_WAIT_ACK(void)
|
||||
{
|
||||
short i=50;
|
||||
SCL_L;
|
||||
@@ -103,7 +104,7 @@ short I2C_WAIT_ACK()
|
||||
I2C_delay();
|
||||
SCL_H;
|
||||
I2C_delay();
|
||||
while(i) {
|
||||
while (i) {
|
||||
if(SDA_read) {
|
||||
I2C_delay();
|
||||
i--;
|
||||
@@ -138,7 +139,7 @@ void I2C_SEND_DATA(char SendByte)
|
||||
I2C_delay();
|
||||
}
|
||||
|
||||
char I2C_READ()
|
||||
char I2C_READ(void)
|
||||
{
|
||||
short i=8;
|
||||
char ReceiveByte=0;
|
||||
@@ -158,7 +159,7 @@ char I2C_READ()
|
||||
return ReceiveByte;
|
||||
}
|
||||
|
||||
void I2C_EE_Init()
|
||||
void I2C_EE_Init(void)
|
||||
{
|
||||
/* GPIO Periph clock enable */
|
||||
RCC_AHB1PeriphClockCmd(I2C_EE_GPIO_CLK, ENABLE);
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
#define WP_H do{I2C_EE_WP_GPIO->BSRRL = I2C_EE_WP;}while(0)
|
||||
#define WP_L do{I2C_EE_WP_GPIO->BSRRH = I2C_EE_WP;}while(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void I2C_EE_Init(void);
|
||||
void I2C_EE_ByteWrite(uint8_t* pBuffer, uint16_t WriteAddr);
|
||||
@@ -42,7 +46,11 @@ void I2C_EE_BufferRead(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRe
|
||||
void I2C_EE_WaitEepromStandbyState(void);
|
||||
|
||||
void I2C_set_volume(register uint8_t volume);
|
||||
uint8_t I2C_read_volume();
|
||||
uint8_t I2C_read_volume(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __I2C_EE_H */
|
||||
|
||||
|
||||
@@ -230,14 +230,17 @@ bool switchState(EnumKeys enuk)
|
||||
void keysInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
/* GPIOC GPIOD clock enable */
|
||||
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBUTTON, ENABLE);
|
||||
|
||||
/* GPIO Configuration*/
|
||||
#if defined(REV3)
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L
|
||||
| PIN_TRIM_LV_DN | PIN_TRIM_LV_UP
|
||||
| PIN_SW_A_L | PIN_SW_D_L | PIN_SW_F | PIN_SW_C_L | PIN_SW_D_H | PIN_SW_H;
|
||||
#elif defined(REVPLUS)
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L
|
||||
| PIN_TRIM_LV_DN | PIN_TRIM_LV_UP
|
||||
| PIN_SW_F | PIN_SW_A_L | PIN_SW_B_H | PIN_SW_B_L | PIN_SW_C_H | PIN_SW_D_H | PIN_SW_D_L | PIN_SW_G_H | PIN_SW_G_L;
|
||||
#else
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L
|
||||
| PIN_TRIM_LV_DN | PIN_TRIM_LV_UP
|
||||
@@ -249,29 +252,23 @@ void keysInit()
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_Init(GPIOE, &GPIO_InitStructure);
|
||||
|
||||
#if defined(REVPLUS)
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_MENU | PIN_BUTTON_EXIT | PIN_BUTTON_PAGE | PIN_SW_H;
|
||||
#else
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_MENU | PIN_BUTTON_EXIT | PIN_BUTTON_PAGE;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
#endif
|
||||
GPIO_Init(GPIOD, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_TRIM_RV_DN | PIN_TRIM_RV_UP | PIN_TRIM_RH_L | PIN_TRIM_RH_R;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
|
||||
#if defined(REV3)
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_SW_B_H | PIN_SW_B_L | PIN_SW_C_H | PIN_SW_E_L | PIN_SW_E_H | PIN_SW_A_H | PIN_SW_G_L;
|
||||
#elif defined(REVPLUS)
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_SW_E_L | PIN_SW_E_H | PIN_SW_A_H;
|
||||
#else
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_SW_E_L | PIN_SW_E_H | PIN_SW_A_H | PIN_SW_D_L;
|
||||
#endif
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
#if defined(REV3)
|
||||
@@ -279,10 +276,6 @@ void keysInit()
|
||||
#else
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_SW_C_L;
|
||||
#endif
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "../opentx.h"
|
||||
#include "../../opentx.h"
|
||||
|
||||
#define WriteData(x) AspiData(x)
|
||||
#define WriteCommand(x) AspiCmd(x)
|
||||
#define CONTRAST_OFS 5
|
||||
#define CONTRAST_OFS 5
|
||||
|
||||
static void LCD_Init()
|
||||
{
|
||||
@@ -21,7 +21,11 @@ static void LCD_Init()
|
||||
AspiCmd(0x25); //Temperature compensation curve definition: 0x25 = -0.05%/oC
|
||||
AspiCmd(0xEA); //set bias=1/10 :Command table NO.27
|
||||
AspiCmd(0x81); //Set Vop
|
||||
AspiCmd(g_eeGeneral.contrast+CONTRAST_OFS); //0--255
|
||||
#if defined(BOOT)
|
||||
AspiCmd(CONTRAST_OFS+25);
|
||||
#else
|
||||
AspiCmd(CONTRAST_OFS+g_eeGeneral.contrast);
|
||||
#endif
|
||||
AspiCmd(0xA6); //inverse display off
|
||||
AspiCmd(0xD1); //SET RGB:Command table NO.21 .SET RGB or BGR. D1=RGB
|
||||
AspiCmd(0xD5); //set color mode 4K and 12bits :Command table NO.22
|
||||
@@ -94,12 +98,12 @@ const uint8_t lcdPalette[4] = { 0, 0x03, 0x06, 0x0F };
|
||||
|
||||
#define LCD_WRITE_BIT(bit) \
|
||||
if (bit) \
|
||||
GPIOD->BSRRL = PIN_LCD_MOSI; \
|
||||
LCD_MOSI_HIGH(); \
|
||||
else \
|
||||
GPIOD->BSRRH = PIN_LCD_MOSI; \
|
||||
GPIOD->BSRRH = PIN_LCD_CLK; /* Clock low */ \
|
||||
LCD_MOSI_LOW(); \
|
||||
LCD_CLK_LOW(); \
|
||||
__no_operation(); \
|
||||
GPIOD->BSRRL = PIN_LCD_CLK; /* Clock high */
|
||||
LCD_CLK_HIGH();
|
||||
|
||||
void lcdRefresh()
|
||||
{
|
||||
@@ -133,24 +137,45 @@ static void LCD_BL_Config()
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBL, ENABLE);
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_BL;
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIOBL, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, Pin_BL_AF);
|
||||
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, GPIO_AF_TIM10);
|
||||
#if defined(REVPLUS)
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BLW;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIOBL, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BLW, Pin_BLW_AF);
|
||||
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN ; // Enable clock
|
||||
TIM4->ARR = 100 ;
|
||||
TIM4->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1;
|
||||
TIM4->CCMR1 = TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2M_2 ; // PWM
|
||||
TIM4->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2 ; // PWM
|
||||
TIM4->CCER = TIM_CCER_CC4E | TIM_CCER_CC2E ;
|
||||
|
||||
int BacklightBrightness = 40 ;
|
||||
TIM4->CCR2 = BacklightBrightness ;
|
||||
TIM4->CCR4 = BacklightBrightness ;
|
||||
TIM4->EGR = 0 ;
|
||||
TIM4->CR1 = TIM_CR1_CEN ; // Counter enable
|
||||
#else
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM10EN ; // Enable clock
|
||||
TIM10->ARR = 100 ;
|
||||
TIM10->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1;
|
||||
TIM10->CCMR1 = 0x60 ; // PWM
|
||||
TIM10->CCER = 1 ;
|
||||
|
||||
TIM10->CCR1 = 80;
|
||||
TIM10->EGR = 0 ;
|
||||
TIM10->CR1 = 1 ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Init the anolog spi gpio
|
||||
@@ -162,21 +187,26 @@ static void LCD_Hardware_Init()
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
/*!< Configure lcd CLK\ MOSI\ A0pin in output pushpull mode *************/
|
||||
GPIO_InitStructure.GPIO_Pin =PIN_LCD_MOSI | PIN_LCD_CLK | PIN_LCD_A0;
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_LCD_MOSI | PIN_LCD_CLK | PIN_LCD_A0;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_LCD, &GPIO_InitStructure);
|
||||
GPIO_Init(GPIO_LCD_SPI, &GPIO_InitStructure);
|
||||
|
||||
LCD_NCS_HIGH();
|
||||
|
||||
/*!< Configure lcd NCS pin in output pushpull mode ,PULLUP *************/
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_LCD_NCS |PIN_LCD_RST;
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_LCD_NCS;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(GPIO_LCD_NCS, &GPIO_InitStructure);
|
||||
|
||||
GPIO_Init(GPIO_LCD, &GPIO_InitStructure);
|
||||
/*!< Configure lcd RST pin in output pushpull mode ,PULLUP *************/
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_LCD_RST;
|
||||
GPIO_Init(GPIO_LCD_RST, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
//275us
|
||||
|
||||
@@ -259,8 +259,8 @@ static void init_pa10_pxx()
|
||||
DMA2->HIFCR = DMA_HIFCR_CTCIF6 | DMA_HIFCR_CHTIF6 | DMA_HIFCR_CTEIF6 | DMA_HIFCR_CDMEIF6 | DMA_HIFCR_CFEIF6 ; // Write ones to clear bits
|
||||
DMA2_Stream6->CR = DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_2 | DMA_SxCR_PL_0 | DMA_SxCR_MSIZE_0
|
||||
| DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_PFCTRL ;
|
||||
DMA2_Stream6->PAR = CONVERT_PTR(&TIM1->DMAR);
|
||||
DMA2_Stream6->M0AR = CONVERT_PTR(&pxxStream[INTERNAL_MODULE][1]);
|
||||
DMA2_Stream6->PAR = CONVERT_PTR_UINT(&TIM1->DMAR);
|
||||
DMA2_Stream6->M0AR = CONVERT_PTR_UINT(&pxxStream[INTERNAL_MODULE][1]);
|
||||
// DMA2_Stream2->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
|
||||
// DMA2_Stream2->NDTR = 100 ;
|
||||
DMA2_Stream6->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
@@ -344,7 +344,7 @@ extern "C" void TIM1_CC_IRQHandler()
|
||||
if (s_current_protocol[INTERNAL_MODULE] == PROTO_PXX) {
|
||||
DMA2_Stream6->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
DMA2->HIFCR = DMA_HIFCR_CTCIF6 | DMA_HIFCR_CHTIF6 | DMA_HIFCR_CTEIF6 | DMA_HIFCR_CDMEIF6 | DMA_HIFCR_CFEIF6 ; // Write ones to clear bits
|
||||
DMA2_Stream6->M0AR = CONVERT_PTR(&pxxStream[INTERNAL_MODULE][1]);
|
||||
DMA2_Stream6->M0AR = CONVERT_PTR_UINT(&pxxStream[INTERNAL_MODULE][1]);
|
||||
DMA2_Stream6->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
TIM1->CCR3 = pxxStream[INTERNAL_MODULE][0];
|
||||
TIM1->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
@@ -422,8 +422,8 @@ static void init_pa7_pxx()
|
||||
DMA2->LIFCR = DMA_LIFCR_CTCIF2 | DMA_LIFCR_CHTIF2 | DMA_LIFCR_CTEIF2 | DMA_LIFCR_CDMEIF2 | DMA_LIFCR_CFEIF2 ; // Write ones to clear bits
|
||||
DMA2_Stream2->CR = DMA_SxCR_CHSEL_0 | DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_2 | DMA_SxCR_PL_0 | DMA_SxCR_MSIZE_0
|
||||
| DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_PFCTRL ;
|
||||
DMA2_Stream2->PAR = CONVERT_PTR(&TIM8->DMAR);
|
||||
DMA2_Stream2->M0AR = CONVERT_PTR(&pxxStream[EXTERNAL_MODULE][1]);
|
||||
DMA2_Stream2->PAR = CONVERT_PTR_UINT(&TIM8->DMAR);
|
||||
DMA2_Stream2->M0AR = CONVERT_PTR_UINT(&pxxStream[EXTERNAL_MODULE][1]);
|
||||
// DMA2_Stream2->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
|
||||
// DMA2_Stream2->NDTR = 100 ;
|
||||
DMA2_Stream2->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
@@ -496,8 +496,8 @@ static void init_pa7_dsm2()
|
||||
DMA2->LIFCR = DMA_LIFCR_CTCIF2 | DMA_LIFCR_CHTIF2 | DMA_LIFCR_CTEIF2 | DMA_LIFCR_CDMEIF2 | DMA_LIFCR_CFEIF2 ; // Write ones to clear bits
|
||||
DMA2_Stream2->CR = DMA_SxCR_CHSEL_0 | DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_2 | DMA_SxCR_PL_0 | DMA_SxCR_MSIZE_0
|
||||
| DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_PFCTRL ;
|
||||
DMA2_Stream2->PAR = CONVERT_PTR(&TIM8->DMAR);
|
||||
DMA2_Stream2->M0AR = CONVERT_PTR(&dsm2Stream[1]);
|
||||
DMA2_Stream2->PAR = CONVERT_PTR_UINT(&TIM8->DMAR);
|
||||
DMA2_Stream2->M0AR = CONVERT_PTR_UINT(&dsm2Stream[1]);
|
||||
// DMA2_Stream2->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
|
||||
// DMA2_Stream2->NDTR = 100 ;
|
||||
DMA2_Stream2->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
@@ -586,7 +586,7 @@ extern "C" void TIM8_CC_IRQHandler()
|
||||
if (s_current_protocol[EXTERNAL_MODULE] == PROTO_PXX) {
|
||||
DMA2_Stream2->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
DMA2->LIFCR = DMA_LIFCR_CTCIF2 | DMA_LIFCR_CHTIF2 | DMA_LIFCR_CTEIF2 | DMA_LIFCR_CDMEIF2 | DMA_LIFCR_CFEIF2 ; // Write ones to clear bits
|
||||
DMA2_Stream2->M0AR = CONVERT_PTR(&pxxStream[EXTERNAL_MODULE][1]);
|
||||
DMA2_Stream2->M0AR = CONVERT_PTR_UINT(&pxxStream[EXTERNAL_MODULE][1]);
|
||||
DMA2_Stream2->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
TIM8->CCR1 = pxxStream[EXTERNAL_MODULE][0];
|
||||
TIM8->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
@@ -595,7 +595,7 @@ extern "C" void TIM8_CC_IRQHandler()
|
||||
else if (s_current_protocol[EXTERNAL_MODULE] >= PROTO_DSM2_LP45 && s_current_protocol[EXTERNAL_MODULE] <= PROTO_DSM2_DSMX) {
|
||||
DMA2_Stream2->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
DMA2->LIFCR = DMA_LIFCR_CTCIF2 | DMA_LIFCR_CHTIF2 | DMA_LIFCR_CTEIF2 | DMA_LIFCR_CDMEIF2 | DMA_LIFCR_CFEIF2 ; // Write ones to clear bits
|
||||
DMA2_Stream2->M0AR = CONVERT_PTR(&dsm2Stream[1]);
|
||||
DMA2_Stream2->M0AR = CONVERT_PTR_UINT(&dsm2Stream[1]);
|
||||
DMA2_Stream2->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
TIM8->CCR1 = dsm2Stream[0];
|
||||
TIM8->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
|
||||
@@ -34,26 +34,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../opentx.h"
|
||||
|
||||
void pwrOff()
|
||||
{
|
||||
GPIO_ResetBits(GPIOPWR,PIN_MCU_PWR);
|
||||
}
|
||||
|
||||
uint32_t pwrCheck()
|
||||
{
|
||||
#if defined(SIMU)
|
||||
return e_power_on;
|
||||
#else
|
||||
if (GPIO_ReadInputDataBit(GPIOPWR, PIN_PWR_STATUS) == Bit_RESET)
|
||||
return e_power_on;
|
||||
else if (usbPlugged())
|
||||
return e_power_usb;
|
||||
else
|
||||
return e_power_off;
|
||||
#endif
|
||||
}
|
||||
#include "board_taranis.h"
|
||||
#include "../../pwr.h"
|
||||
|
||||
void pwrInit()
|
||||
{
|
||||
@@ -84,13 +66,21 @@ void pwrInit()
|
||||
GPIO_Init(GPIOPWRLED, &GPIO_InitStructure);
|
||||
|
||||
#if !defined(REV3)
|
||||
GPIO_ResetBits(GPIOPWR, PIN_INT_RF_PWR | PIN_EXT_RF_PWR);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_INT_RF_PWR | PIN_EXT_RF_PWR;
|
||||
GPIO_ResetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_INT_RF_PWR;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIOPWR, &GPIO_InitStructure);
|
||||
GPIO_Init(GPIO_INT_RF_PWR, &GPIO_InitStructure);
|
||||
|
||||
GPIO_ResetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_EXT_RF_PWR;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_EXT_RF_PWR, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_TRNDET;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
@@ -101,5 +91,25 @@ void pwrInit()
|
||||
#endif
|
||||
|
||||
// Soft power ON
|
||||
GPIO_SetBits(GPIOPWR,PIN_MCU_PWR);
|
||||
GPIO_SetBits(GPIOPWR, PIN_MCU_PWR);
|
||||
}
|
||||
|
||||
void pwrOff()
|
||||
{
|
||||
GPIO_ResetBits(GPIOPWR, PIN_MCU_PWR);
|
||||
}
|
||||
|
||||
// TODO enums should be UPPERCASE
|
||||
uint32_t pwrCheck()
|
||||
{
|
||||
#if defined(SIMU)
|
||||
return e_power_on;
|
||||
#else
|
||||
if (GPIO_ReadInputDataBit(GPIOPWR, PIN_PWR_STATUS) == Bit_RESET)
|
||||
return e_power_on;
|
||||
else if (usbPlugged())
|
||||
return e_power_usb;
|
||||
else
|
||||
return e_power_off;
|
||||
#endif
|
||||
}
|
||||
+176
-165
@@ -1,165 +1,176 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : stm32_flash.ld
|
||||
**
|
||||
** Abstract : Linker script for STM32F205 Device with
|
||||
** 0.5MByte FLASH, 128KByte SRAM
|
||||
**
|
||||
** Set heap size, stack size and stack location according
|
||||
** to application requirements.
|
||||
**
|
||||
** Set memory bank area and size if external memory is used.
|
||||
**
|
||||
** Target : STMicroelectronics STM32
|
||||
**
|
||||
** Environment : Atollic TrueSTUDIO(R)
|
||||
**
|
||||
** Distribution: The file is distributed “as is,” without any warranty
|
||||
** of any kind.
|
||||
**
|
||||
** (c)Copyright Atollic AB.
|
||||
** You may use this file as-is or modify it according to the needs of your
|
||||
** project. Distribution of this file (unmodified or modified) is not
|
||||
** permitted. Atollic AB permit registered Atollic TrueSTUDIO(R) users the
|
||||
** rights to distribute the assembled, compiled & linked contents of this
|
||||
** file as part of an application binary file, provided that it is built
|
||||
** using the Atollic TrueSTUDIO(R) toolchain.
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_Min_Heap_Size = 0; /* required amount of heap */
|
||||
_Min_Stack_Size = 0x200; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
|
||||
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into FLASH */
|
||||
|
||||
/* The program code and other data goes into FLASH */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} >FLASH
|
||||
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} >FLASH
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >FLASH
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >FLASH
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(.fini_array*))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >FLASH
|
||||
|
||||
/* used by the startup to initialize data */
|
||||
_sidata = .;
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data : AT ( _sidata )
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} >RAM
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
_sbss = .; /* define a global symbol at bss start */
|
||||
__bss_start__ = _sbss;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* define a global symbol at bss end */
|
||||
__bss_end__ = _ebss;
|
||||
} >RAM
|
||||
|
||||
PROVIDE ( end = _ebss );
|
||||
PROVIDE ( _end = _ebss );
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
. = . + _Min_Heap_Size;
|
||||
. = . + _Min_Stack_Size;
|
||||
. = ALIGN(4);
|
||||
} >RAM
|
||||
|
||||
PROVIDE ( _estack = ORIGIN(RAM) + LENGTH(RAM) );
|
||||
|
||||
/* MEMORY_bank1 section, code must be located here explicitly */
|
||||
/* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
|
||||
.memory_b1_text :
|
||||
{
|
||||
*(.mb1text) /* .mb1text sections (code) */
|
||||
*(.mb1text*) /* .mb1text* sections (code) */
|
||||
*(.mb1rodata) /* read-only data (constants) */
|
||||
*(.mb1rodata*)
|
||||
} >MEMORY_B1
|
||||
|
||||
/* Remove information from the standard libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
libc.a ( * )
|
||||
libm.a ( * )
|
||||
libgcc.a ( * )
|
||||
}
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
/*
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : stm32_flash.ld
|
||||
**
|
||||
** Abstract : Linker script for STM32F205 Device with
|
||||
** 0.5MByte FLASH, 128KByte SRAM
|
||||
**
|
||||
** Set heap size, stack size and stack location according
|
||||
** to application requirements.
|
||||
**
|
||||
** Set memory bank area and size if external memory is used.
|
||||
**
|
||||
** Target : STMicroelectronics STM32
|
||||
**
|
||||
** Environment : Atollic TrueSTUDIO(R)
|
||||
**
|
||||
** Distribution: The file is distributed “as is,” without any warranty
|
||||
** of any kind.
|
||||
**
|
||||
** (c)Copyright Atollic AB.
|
||||
** You may use this file as-is or modify it according to the needs of your
|
||||
** project. Distribution of this file (unmodified or modified) is not
|
||||
** permitted. Atollic AB permit registered Atollic TrueSTUDIO(R) users the
|
||||
** rights to distribute the assembled, compiled & linked contents of this
|
||||
** file as part of an application binary file, provided that it is built
|
||||
** using the Atollic TrueSTUDIO(R) toolchain.
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20020000; /* end of 128K SRAM */
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_Min_Heap_Size = 0; /* required amount of heap */
|
||||
_Min_Stack_Size = 0x200; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
|
||||
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into FLASH */
|
||||
|
||||
/* The program code and other data goes into FLASH */
|
||||
.text :
|
||||
{
|
||||
FILL(0xFFFF)
|
||||
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
|
||||
KEEP(*(.isr_boot_vector)) /* Startup code */
|
||||
*(.bootrodata)
|
||||
*(.bootrodata.*)
|
||||
|
||||
. = ALIGN(32768); /* Align the start of the main program */
|
||||
_stext = .; /* Provide the name for the start of this section */
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} >FLASH
|
||||
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} >FLASH
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >FLASH
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >FLASH
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(.fini_array*))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >FLASH
|
||||
|
||||
/* used by the startup to initialize data */
|
||||
_sidata = .;
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data : AT ( _sidata )
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} >RAM
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
_sbss = .; /* define a global symbol at bss start */
|
||||
__bss_start__ = _sbss;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* define a global symbol at bss end */
|
||||
__bss_end__ = _ebss;
|
||||
} >RAM
|
||||
|
||||
PROVIDE ( end = _ebss );
|
||||
PROVIDE ( _end = _ebss );
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
. = . + _Min_Heap_Size;
|
||||
. = . + _Min_Stack_Size;
|
||||
. = ALIGN(4);
|
||||
} >RAM
|
||||
|
||||
/* MEMORY_bank1 section, code must be located here explicitly */
|
||||
/* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
|
||||
.memory_b1_text :
|
||||
{
|
||||
*(.mb1text) /* .mb1text sections (code) */
|
||||
*(.mb1text*) /* .mb1text* sections (code) */
|
||||
*(.mb1rodata) /* read-only data (constants) */
|
||||
*(.mb1rodata*)
|
||||
} >MEMORY_B1
|
||||
|
||||
/* Remove information from the standard libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
libc.a ( * )
|
||||
libm.a ( * )
|
||||
libgcc.a ( * )
|
||||
}
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : stm32_flashboot.ld
|
||||
**
|
||||
** Abstract : Linker script for STM32F205 Device with
|
||||
** 0.5MByte FLASH, 128KByte SRAM
|
||||
**
|
||||
** Set heap size, stack size and stack location according
|
||||
** to application requirements.
|
||||
**
|
||||
** Set memory bank area and size if external memory is used.
|
||||
**
|
||||
** Target : STMicroelectronics STM32
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20020000; /* end of 128K SRAM */
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_Min_Heap_Size = 0; /* required amount of heap */
|
||||
_Min_Stack_Size = 0x200; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
|
||||
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into FLASH */
|
||||
|
||||
/* The program code and other data goes into FLASH */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
*(.version)
|
||||
. = ALIGN(4); /* Align the start of the text part */
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} >RAM
|
||||
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >RAM
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} >RAM
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >RAM
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >RAM
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(.fini_array*))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >RAM
|
||||
|
||||
/* used by the startup to initialize data */
|
||||
_sidata = .;
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data : AT ( _sidata )
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} >RAM
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
_sbss = .; /* define a global symbol at bss start */
|
||||
__bss_start__ = _sbss;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* define a global symbol at bss end */
|
||||
__bss_end__ = _ebss;
|
||||
} >RAM
|
||||
|
||||
PROVIDE ( end = _ebss );
|
||||
PROVIDE ( _end = _ebss );
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
. = . + _Min_Heap_Size;
|
||||
. = . + _Min_Stack_Size;
|
||||
. = ALIGN(4);
|
||||
} >RAM
|
||||
|
||||
/* MEMORY_bank1 section, code must be located here explicitly */
|
||||
/* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
|
||||
.memory_b1_text :
|
||||
{
|
||||
*(.mb1text) /* .mb1text sections (code) */
|
||||
*(.mb1text*) /* .mb1text* sections (code) */
|
||||
*(.mb1rodata) /* read-only data (constants) */
|
||||
*(.mb1rodata*)
|
||||
} >MEMORY_B1
|
||||
|
||||
/* Remove information from the standard libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
libc.a ( * )
|
||||
libm.a ( * )
|
||||
libgcc.a ( * )
|
||||
}
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
@@ -126,12 +126,13 @@ extern "C" void TIM3_IRQHandler()
|
||||
|
||||
// We process g_ppmInsright here to make servo movement as smooth as possible
|
||||
// while under trainee control
|
||||
if ((val>4000) && (val < 19000)) { // G: Prioritize reset pulse. (Needed when less than 16 incoming pulses)
|
||||
if (val>4000 && val<19000) { // G: Prioritize reset pulse. (Needed when less than 16 incoming pulses)
|
||||
ppmInState = 1; // triggered
|
||||
}
|
||||
else {
|
||||
if (ppmInState && (ppmInState<=16)) {
|
||||
if ((val>800) && (val<2200)) {
|
||||
if (ppmInState>0 && ppmInState<=16) {
|
||||
if (val>800 && val<2200) {
|
||||
ppmInValid = 100;
|
||||
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -82,9 +82,15 @@ void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev)
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
|
||||
RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE) ;
|
||||
}
|
||||
|
||||
void USB_OTG_BSP_Deinit(USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USB_OTG_BSP_EnableInterrupt
|
||||
* Enabele USB Global interrupt
|
||||
* Enable USB Global interrupt
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
@@ -99,6 +105,26 @@ void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev)
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USB_OTG_BSP_DisableInterrupt
|
||||
* Disable USB Global interrupt
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void USB_OTG_BSP_DisableInterrupt(USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
|
||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
|
||||
NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief USB_OTG_BSP_uDelay
|
||||
* This function provides delay time in micro sec
|
||||
|
||||
@@ -31,11 +31,6 @@
|
||||
|
||||
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h"
|
||||
|
||||
#define HID_IN_EP 0x81
|
||||
#define HID_OUT_EP 0x01
|
||||
|
||||
#define HID_IN_PACKET 4
|
||||
#define HID_OUT_PACKET 4
|
||||
|
||||
/* USB Core and PHY interface configuration.
|
||||
Tip: To avoid modifying these defines each time you need to change the USB
|
||||
@@ -159,15 +154,17 @@
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
|
||||
/* __packed keyword used to decrease the data type alignment to 1-byte */
|
||||
#if defined (__CC_ARM) /* ARM Compiler */
|
||||
#define __packed __packed
|
||||
#elif defined (__ICCARM__) /* IAR Compiler */
|
||||
#define __packed __packed
|
||||
#elif defined ( __GNUC__ ) /* GNU Compiler */
|
||||
#define __packed __attribute__ ((__packed__))
|
||||
#elif defined (__TASKING__) /* TASKING Compiler */
|
||||
#define __packed __unaligned
|
||||
#endif /* __CC_ARM */
|
||||
#if !defined(__packed)
|
||||
#if defined (__CC_ARM) /* ARM Compiler */
|
||||
#define __packed __packed
|
||||
#elif defined (__ICCARM__) /* IAR Compiler */
|
||||
#define __packed __packed
|
||||
#elif defined ( __GNUC__ ) /* GNU Compiler */
|
||||
#define __packed __attribute__ ((__packed__))
|
||||
#elif defined (__TASKING__) /* TASKING Compiler */
|
||||
#define __packed __unaligned
|
||||
#endif /* __CC_ARM */
|
||||
#endif
|
||||
|
||||
#endif //__USB_CONF__H__
|
||||
|
||||
|
||||
Executable
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
*
|
||||
* opentx 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 "board_taranis.h"
|
||||
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd_int.h"
|
||||
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_bsp.h"
|
||||
|
||||
int usbPlugged(void)
|
||||
{
|
||||
//debounce
|
||||
static uint8_t debounced_state = 0;
|
||||
static uint8_t last_state = 0;
|
||||
if ( GPIO_ReadInputDataBit(GPIOA, PIN_FS_VBUS) ) {
|
||||
if (last_state) debounced_state = 1;
|
||||
last_state = 1;
|
||||
}
|
||||
else {
|
||||
if (!last_state) debounced_state = 0;
|
||||
last_state = 0;
|
||||
}
|
||||
return debounced_state;
|
||||
}
|
||||
|
||||
USB_OTG_CORE_HANDLE USB_OTG_dev;
|
||||
|
||||
void OTG_FS_IRQHandler(void)
|
||||
{
|
||||
USBD_OTG_ISR_Handler (&USB_OTG_dev);
|
||||
}
|
||||
|
||||
void usbInit(void)
|
||||
{
|
||||
USB_OTG_BSP_Init(&USB_OTG_dev);
|
||||
}
|
||||
|
||||
void usbStart(void)
|
||||
{
|
||||
#if !defined(BOOT)
|
||||
//intialize USB as HID device
|
||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_HID_cb, &USR_cb);
|
||||
#else
|
||||
//intialize USB as MSC device
|
||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb);
|
||||
#endif //!defined(BOOT)
|
||||
}
|
||||
|
||||
|
||||
void usbStop(void)
|
||||
{
|
||||
USBD_DeInit(&USB_OTG_dev);
|
||||
}
|
||||
@@ -46,6 +46,12 @@
|
||||
|
||||
#define MSC_MEDIA_PACKET 4096
|
||||
|
||||
#define HID_IN_EP 0x81
|
||||
#define HID_OUT_EP 0x01
|
||||
|
||||
#define HID_IN_PACKET 9
|
||||
#define HID_OUT_PACKET 9
|
||||
|
||||
|
||||
#endif //__USBD_CONF__H__
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "usbd_req.h"
|
||||
#include "usbd_conf.h"
|
||||
#include "usb_regs.h"
|
||||
#include "board_taranis.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
@@ -54,16 +55,24 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define USBD_VID 0x0483
|
||||
#define USBD_PID 0x5720
|
||||
#define USBD_VID 0x0483
|
||||
|
||||
#define USBD_LANGID_STRING 0x409
|
||||
#define USBD_MANUFACTURER_STRING "FrSky"
|
||||
#define USBD_LANGID_STRING 0x409
|
||||
#define USBD_MANUFACTURER_STRING "FrSky"
|
||||
#define USBD_SERIALNUMBER_FS_STRING "00000000001B"
|
||||
|
||||
#define USBD_PRODUCT_FS_STRING "FrSky Taranis Mass Storage"
|
||||
#define USBD_SERIALNUMBER_FS_STRING "00000000001B"
|
||||
#define USBD_CONFIGURATION_FS_STRING "MSC Config"
|
||||
#define USBD_INTERFACE_FS_STRING "MSC Interface"
|
||||
|
||||
#if defined(BOOT)
|
||||
#define USBD_PID 0x5720
|
||||
#define USBD_PRODUCT_FS_STRING "FrSky Taranis Bootloader"
|
||||
#define USBD_CONFIGURATION_FS_STRING "MSC Config"
|
||||
#define USBD_INTERFACE_FS_STRING "MSC Interface"
|
||||
#else
|
||||
#define USBD_PID 0x5710
|
||||
#define USBD_PRODUCT_FS_STRING "FrSky Taranis Joystick"
|
||||
#define USBD_CONFIGURATION_FS_STRING "HID Config"
|
||||
#define USBD_INTERFACE_FS_STRING "HID Interface"
|
||||
#endif
|
||||
|
||||
USBD_DEVICE USR_desc =
|
||||
{
|
||||
@@ -159,9 +168,7 @@ uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length)
|
||||
*/
|
||||
uint8_t * USBD_USR_ProductStrDescriptor( uint8_t speed , uint16_t *length)
|
||||
{
|
||||
|
||||
USBD_GetString ((uint8_t*)USBD_PRODUCT_FS_STRING, USBD_StrDesc, length);
|
||||
|
||||
return USBD_StrDesc;
|
||||
}
|
||||
|
||||
@@ -188,7 +195,6 @@ uint8_t * USBD_USR_ManufacturerStrDescriptor( uint8_t speed , uint16_t *length)
|
||||
uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length)
|
||||
{
|
||||
USBD_GetString ((uint8_t*)USBD_SERIALNUMBER_FS_STRING, USBD_StrDesc, length);
|
||||
|
||||
return USBD_StrDesc;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,479 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_hid_core.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief This file provides the HID core functions.
|
||||
*
|
||||
* @verbatim
|
||||
*
|
||||
* ===================================================================
|
||||
* HID Class Description
|
||||
* ===================================================================
|
||||
* This module manages the HID class V1.11 following the "Device Class Definition
|
||||
* for Human Interface Devices (HID) Version 1.11 Jun 27, 2001".
|
||||
* This driver implements the following aspects of the specification:
|
||||
* - The Boot Interface Subclass
|
||||
* - The Mouse protocol
|
||||
* - Usage Page : Generic Desktop
|
||||
* - Usage : Joystick)
|
||||
* - Collection : Application
|
||||
*
|
||||
* @note In HS mode and when the DMA is used, all variables and data structures
|
||||
* dealing with the DMA during the transaction process should be 32-bit aligned.
|
||||
*
|
||||
*
|
||||
* @endverbatim
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_hid_core.h"
|
||||
#include "usbd_req.h"
|
||||
#include "usbd_desc.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_HID
|
||||
* @brief usbd core module
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_HID_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_HID_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_HID_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_HID_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
static uint8_t USBD_HID_Init (void *pdev,
|
||||
uint8_t cfgidx);
|
||||
|
||||
static uint8_t USBD_HID_DeInit (void *pdev,
|
||||
uint8_t cfgidx);
|
||||
|
||||
static uint8_t USBD_HID_Setup (void *pdev,
|
||||
USB_SETUP_REQ *req);
|
||||
|
||||
static uint8_t *USBD_HID_GetCfgDesc (uint8_t speed, uint16_t *length);
|
||||
|
||||
static uint8_t USBD_HID_DataIn (void *pdev, uint8_t epnum);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
/*
|
||||
This USB HID endpoint report description defines a device with:
|
||||
* 8 digital buttons
|
||||
* 8 analog axes with 8bit resolution
|
||||
|
||||
Repot packet described as C struct is:
|
||||
|
||||
struct {
|
||||
uint8_t buttons; //bit 0 - button 1, bit 1 - button 2, ..., mapped to channels 9-16, on if channel > 0
|
||||
uint8_t X; //analog value, mapped to channel 1
|
||||
uint8_t Y; //analog value, mapped to channel 2
|
||||
uint8_t Z; //analog value, mapped to channel 3
|
||||
uint8_t Rx; //analog value, mapped to channel 4
|
||||
uint8_t Ry //analog value, mapped to channel 5
|
||||
uint8_t Rz; //analog value, mapped to channel 6
|
||||
uint8_t S1; //analog value, mapped to channel 7
|
||||
uint8_t S2; //analog value, mapped to channel 8
|
||||
}
|
||||
*/
|
||||
__ALIGN_BEGIN static uint8_t HID_JOYSTICK_ReportDesc[] __ALIGN_END =
|
||||
{
|
||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
0x09, 0x05, // USAGE (Game Pad)
|
||||
0xa1, 0x01, // COLLECTION (Application)
|
||||
0xa1, 0x00, // COLLECTION (Physical)
|
||||
0x05, 0x09, // USAGE_PAGE (Button)
|
||||
0x19, 0x01, // USAGE_MINIMUM (Button 1)
|
||||
0x29, 0x08, // USAGE_MAXIMUM (Button 8)
|
||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
||||
0x95, 0x08, // REPORT_COUNT (8)
|
||||
0x75, 0x01, // REPORT_SIZE (1)
|
||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
0x09, 0x30, // USAGE (X)
|
||||
0x09, 0x31, // USAGE (Y)
|
||||
0x09, 0x32, // USAGE (Z)
|
||||
0x09, 0x33, // USAGE (Rx)
|
||||
0x09, 0x34, // USAGE (Ry)
|
||||
0x09, 0x35, // USAGE (Rz)
|
||||
0x09, 0x36, // USAGE (Slider)
|
||||
0x09, 0x36, // USAGE (Slider)
|
||||
0x15, 0x81, // LOGICAL_MINIMUM (-127)
|
||||
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
|
||||
0x75, 0x08, // REPORT_SIZE (8)
|
||||
0x95, 0x08, // REPORT_COUNT (8)
|
||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
0xc0, // END_COLLECTION
|
||||
0xc0 // END_COLLECTION
|
||||
};
|
||||
|
||||
|
||||
/** @defgroup USBD_HID_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
USBD_Class_cb_TypeDef USBD_HID_cb =
|
||||
{
|
||||
USBD_HID_Init,
|
||||
USBD_HID_DeInit,
|
||||
USBD_HID_Setup,
|
||||
NULL, /*EP0_TxSent*/
|
||||
NULL, /*EP0_RxReady*/
|
||||
USBD_HID_DataIn, /*DataIn*/
|
||||
NULL, /*DataOut*/
|
||||
NULL, /*SOF */
|
||||
NULL,
|
||||
NULL,
|
||||
USBD_HID_GetCfgDesc,
|
||||
#ifdef USB_OTG_HS_CORE
|
||||
USBD_HID_GetCfgDesc, /* use same config as per FS */
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN static uint32_t USBD_HID_AltSet __ALIGN_END = 0;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN static uint32_t USBD_HID_Protocol __ALIGN_END = 0;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN static uint32_t USBD_HID_IdleState __ALIGN_END = 0;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
/* USB HID device Configuration Descriptor */
|
||||
__ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||
{
|
||||
0x09, /* bLength: Configuration Descriptor size */
|
||||
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
|
||||
USB_HID_CONFIG_DESC_SIZ,
|
||||
/* wTotalLength: Bytes returned */
|
||||
0x00,
|
||||
0x01, /*bNumInterfaces: 1 interface*/
|
||||
0x01, /*bConfigurationValue: Configuration value*/
|
||||
0x00, /*iConfiguration: Index of string descriptor describing
|
||||
the configuration*/
|
||||
0xE0, /*bmAttributes: bus powered and Support Remote Wake-up */
|
||||
0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/
|
||||
|
||||
/************** Descriptor of Joystick Mouse interface ****************/
|
||||
/* 09 */
|
||||
0x09, /*bLength: Interface Descriptor size*/
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE,/*bDescriptorType: Interface descriptor type*/
|
||||
0x00, /*bInterfaceNumber: Number of Interface*/
|
||||
0x00, /*bAlternateSetting: Alternate setting*/
|
||||
0x01, /*bNumEndpoints*/
|
||||
0x03, /*bInterfaceClass: HID*/
|
||||
0x00 /*0x01*/, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
|
||||
0x00 /*0x02*/, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
|
||||
0, /*iInterface: Index of string descriptor*/
|
||||
/******************** Descriptor of Joystick Mouse HID ********************/
|
||||
/* 18 */
|
||||
0x09, /*bLength: HID Descriptor size*/
|
||||
HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
|
||||
0x11, /*bcdHID: HID Class Spec release number*/
|
||||
0x01,
|
||||
0x00, /*bCountryCode: Hardware target country*/
|
||||
0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/
|
||||
0x22, /*bDescriptorType*/
|
||||
sizeof(HID_JOYSTICK_ReportDesc),/*wItemLength: Total length of Report descriptor*/
|
||||
0x00,
|
||||
/******************** Descriptor of Mouse endpoint ********************/
|
||||
/* 27 */
|
||||
0x07, /*bLength: Endpoint Descriptor size*/
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/
|
||||
|
||||
HID_IN_EP, /*bEndpointAddress: Endpoint Address (IN)*/
|
||||
0x03, /*bmAttributes: Interrupt endpoint*/
|
||||
HID_IN_PACKET, /*wMaxPacketSize: 4 Byte max */
|
||||
0x00,
|
||||
0x0A, /*bInterval: Polling Interval (10 ms)*/
|
||||
/* 34 */
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
static uint8_t ReportSent;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_HID_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief USBD_HID_Init
|
||||
* Initialize the HID interface
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: Configuration index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_HID_Init (void *pdev,
|
||||
uint8_t cfgidx)
|
||||
{
|
||||
|
||||
/* Open EP IN */
|
||||
DCD_EP_Open(pdev,
|
||||
HID_IN_EP,
|
||||
HID_IN_PACKET,
|
||||
USB_OTG_EP_INT);
|
||||
|
||||
/* Open EP OUT */
|
||||
DCD_EP_Open(pdev,
|
||||
HID_OUT_EP,
|
||||
HID_OUT_PACKET,
|
||||
USB_OTG_EP_INT);
|
||||
|
||||
ReportSent = 1;
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_HID_Init
|
||||
* DeInitialize the HID layer
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: Configuration index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_HID_DeInit (void *pdev,
|
||||
uint8_t cfgidx)
|
||||
{
|
||||
/* Close HID EPs */
|
||||
DCD_EP_Close (pdev , HID_IN_EP);
|
||||
DCD_EP_Close (pdev , HID_OUT_EP);
|
||||
|
||||
ReportSent = 1;
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_HID_Setup
|
||||
* Handle the HID specific requests
|
||||
* @param pdev: instance
|
||||
* @param req: usb requests
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_HID_Setup (void *pdev,
|
||||
USB_SETUP_REQ *req)
|
||||
{
|
||||
uint16_t len = 0;
|
||||
uint8_t *pbuf = NULL;
|
||||
|
||||
switch (req->bmRequest & USB_REQ_TYPE_MASK)
|
||||
{
|
||||
case USB_REQ_TYPE_CLASS :
|
||||
switch (req->bRequest)
|
||||
{
|
||||
|
||||
|
||||
case HID_REQ_SET_PROTOCOL:
|
||||
USBD_HID_Protocol = (uint8_t)(req->wValue);
|
||||
break;
|
||||
|
||||
case HID_REQ_GET_PROTOCOL:
|
||||
USBD_CtlSendData (pdev,
|
||||
(uint8_t *)&USBD_HID_Protocol,
|
||||
1);
|
||||
break;
|
||||
|
||||
case HID_REQ_SET_IDLE:
|
||||
USBD_HID_IdleState = (uint8_t)(req->wValue >> 8);
|
||||
break;
|
||||
|
||||
case HID_REQ_GET_IDLE:
|
||||
USBD_CtlSendData (pdev,
|
||||
(uint8_t *)&USBD_HID_IdleState,
|
||||
1);
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_CtlError (pdev, req);
|
||||
return USBD_FAIL;
|
||||
}
|
||||
break;
|
||||
|
||||
case USB_REQ_TYPE_STANDARD:
|
||||
switch (req->bRequest)
|
||||
{
|
||||
case USB_REQ_GET_DESCRIPTOR:
|
||||
if( req->wValue >> 8 == HID_REPORT_DESC)
|
||||
{
|
||||
len = MIN(sizeof(HID_JOYSTICK_ReportDesc) , req->wLength);
|
||||
pbuf = HID_JOYSTICK_ReportDesc; // wiiccReportDescriptor; //
|
||||
}
|
||||
else if( req->wValue >> 8 == HID_DESCRIPTOR_TYPE)
|
||||
{
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
pbuf = USBD_HID_Desc;
|
||||
#else
|
||||
pbuf = USBD_HID_CfgDesc + 0x12;
|
||||
#endif
|
||||
len = MIN(USB_HID_DESC_SIZ , req->wLength);
|
||||
}
|
||||
|
||||
USBD_CtlSendData (pdev,
|
||||
pbuf,
|
||||
len);
|
||||
|
||||
break;
|
||||
|
||||
case USB_REQ_GET_INTERFACE :
|
||||
USBD_CtlSendData (pdev,
|
||||
(uint8_t *)&USBD_HID_AltSet,
|
||||
1);
|
||||
break;
|
||||
|
||||
case USB_REQ_SET_INTERFACE :
|
||||
USBD_HID_AltSet = (uint8_t)(req->wValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief USBD_HID_SendReport
|
||||
* Send HID Report
|
||||
* @param pdev: device instance
|
||||
* @param buff: pointer to report
|
||||
* @retval status
|
||||
*/
|
||||
uint8_t USBD_HID_SendReport (USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t *report,
|
||||
uint16_t len)
|
||||
{
|
||||
if (pdev->dev.device_status == USB_OTG_CONFIGURED )
|
||||
{
|
||||
if ( ReportSent )
|
||||
{
|
||||
ReportSent = 0;
|
||||
DCD_EP_Tx (pdev, HID_IN_EP, report, len);
|
||||
}
|
||||
}
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_HID_GetCfgDesc
|
||||
* return configuration descriptor
|
||||
* @param speed : current device speed
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
static uint8_t *USBD_HID_GetCfgDesc (uint8_t speed, uint16_t *length)
|
||||
{
|
||||
*length = sizeof (USBD_HID_CfgDesc);
|
||||
return USBD_HID_CfgDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_HID_DataIn
|
||||
* handle data IN Stage
|
||||
* @param pdev: device instance
|
||||
* @param epnum: endpoint index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_HID_DataIn (void *pdev,
|
||||
uint8_t epnum)
|
||||
{
|
||||
ReportSent = 1;
|
||||
/* Ensure that the FIFO is empty before a new transfer, this condition could
|
||||
be caused by a new transfer before the end of the previous transfer */
|
||||
DCD_EP_Flush(pdev, HID_IN_EP);
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -26,8 +26,8 @@
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "../opentx.h"
|
||||
#include "../FatFs/diskio.h"
|
||||
#include "../../opentx.h"
|
||||
#include "../../FatFs/diskio.h"
|
||||
#include "board_taranis.h"
|
||||
|
||||
extern "C" {
|
||||
@@ -35,8 +35,6 @@ extern "C" {
|
||||
#include "usbd_msc_mem.h"
|
||||
#include "usb_conf.h"
|
||||
|
||||
void eeprom_read_block (void *pointer_ram, uint16_t pointer_eeprom, size_t size);
|
||||
|
||||
#define STORAGE_LUN_NBR 2
|
||||
#define BLOCKSIZE 512
|
||||
|
||||
@@ -141,7 +139,7 @@ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_si
|
||||
{
|
||||
if (lun == 1) {
|
||||
*block_size = BLOCKSIZE;
|
||||
*block_num = EESIZE/BLOCKSIZE + 3 ;
|
||||
*block_num = 3 + EESIZE/BLOCKSIZE + FLASHSIZE/BLOCKSIZE;
|
||||
}
|
||||
else {
|
||||
if (!SD_CARD_PRESENT())
|
||||
@@ -163,6 +161,19 @@ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_si
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t lunReady[2] ;
|
||||
|
||||
void usbPluggedIn()
|
||||
{
|
||||
if (lunReady[0] == 0) {
|
||||
lunReady[0] = 1;
|
||||
}
|
||||
|
||||
if (lunReady[1] == 0) {
|
||||
lunReady[1] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief check whether the medium is ready
|
||||
* @param lun : logical unit number
|
||||
@@ -171,9 +182,15 @@ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_si
|
||||
int8_t STORAGE_IsReady (uint8_t lun)
|
||||
{
|
||||
if (lun == 1) {
|
||||
return 0;
|
||||
if (lunReady[1] == 0) {
|
||||
return -1 ;
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
else {
|
||||
if (lunReady[0] == 0) {
|
||||
return -1 ;
|
||||
}
|
||||
return SD_CARD_PRESENT() ? 0 : -1;
|
||||
}
|
||||
}
|
||||
@@ -205,14 +222,11 @@ int8_t STORAGE_Read (uint8_t lun,
|
||||
uint16_t blk_len)
|
||||
{
|
||||
if (lun == 1) {
|
||||
if (fat12Read(buf, blk_addr, blk_len) != 0) {
|
||||
if (fat12Read(buf, blk_addr, blk_len) != 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (SD_ReadSectors(buf,
|
||||
blk_addr,
|
||||
blk_len) != 0) {
|
||||
if (SD_ReadSectors(buf, blk_addr, blk_len) != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -240,9 +254,7 @@ int8_t STORAGE_Write (uint8_t lun,
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
if (SD_WriteSectors(buf,
|
||||
blk_addr,
|
||||
blk_len) != 0)
|
||||
if (SD_WriteSectors(buf, blk_addr, blk_len) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -267,132 +279,133 @@ int8_t STORAGE_GetMaxLun (void)
|
||||
*/
|
||||
const char g_FATboot[BLOCKSIZE] =
|
||||
{
|
||||
0xeb, 0x3c, 0x90, // Jump instruction.
|
||||
0x39, 0x58, 0x20, 0x54, 0x45, 0x41, 0x4D, 0x00, // OEM Name
|
||||
0x00, 0x02, // Bytes per sector
|
||||
0x01, // Sectors per FS cluster.
|
||||
0x01, 0x00, // Reserved sector count
|
||||
|
||||
0x01, // Number of FATs
|
||||
0x10, 0x00, // Number of root directory entries
|
||||
(EESIZE/BLOCKSIZE)+3, 0x00, // Total sectors = 131
|
||||
0xf8, // Media descriptor
|
||||
0x01, 0x00, // Sectors per FAT table
|
||||
0x20, 0x00, // Sectors per track
|
||||
0x40, 0x00, // Number of heads
|
||||
0x00, 0x00, 0x00, 0x00, // Number of hidden sectors
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, // Large number of sectors.
|
||||
0x00, // Physical drive number
|
||||
0x00, // Reserved
|
||||
0x29, // Extended boot signature
|
||||
0xCE, 0xFA, 0x5C, 0xD1, // Disk ID (serial number)
|
||||
0x56, 0x49, 0x52, 0x54, 0x46, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, // Volume label
|
||||
0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, // FAT file system type
|
||||
0x00, 0x00, // OS boot code
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
|
||||
0xeb, 0x3c, 0x90, // Jump instruction.
|
||||
0x39, 0x58, 0x20, 0x54, 0x45, 0x41, 0x4D, 0x00, // OEM Name
|
||||
0x00, 0x02, // Bytes per sector
|
||||
0x08, // Sectors per FS cluster.
|
||||
0x01, 0x00, // Reserved sector count
|
||||
|
||||
0x01, // Number of FATs
|
||||
0x10, 0x00, // Number of root directory entries
|
||||
3+(EESIZE/BLOCKSIZE), (FLASHSIZE/BLOCKSIZE)>>8, // Total sectors
|
||||
0xf8, // Media descriptor
|
||||
0x01, 0x00, // Sectors per FAT table
|
||||
0x20, 0x00, // Sectors per track
|
||||
0x40, 0x00, // Number of heads
|
||||
0x00, 0x00, 0x00, 0x00, // Number of hidden sectors
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, // Large number of sectors.
|
||||
0x00, // Physical drive number
|
||||
0x00, // Reserved
|
||||
0x29, // Extended boot signature
|
||||
0xCE, 0xFA, 0x5C, 0xD1, // Disk ID (serial number)
|
||||
0x56, 0x49, 0x52, 0x54, 0x46, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, // Volume label
|
||||
0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, // FAT file system type
|
||||
0x00, 0x00, // OS boot code
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
|
||||
};
|
||||
|
||||
#if defined(REV4a)
|
||||
const char g_FAT[BLOCKSIZE] =
|
||||
{
|
||||
0xF8, 0xFF, 0xFF, 0x03, 0x40, 0x00, 0x05, 0x60, 0x00, 0x07, 0x80, 0x00, 0x09, 0xA0, 0x00, 0x0B,
|
||||
0xC0, 0x00, 0x0D, 0xE0, 0x00, 0x0F, 0x00, 0x01, 0x11, 0x20, 0x01, 0x13, 0x40, 0x01, 0x15, 0x60,
|
||||
0x01, 0x17, 0x80, 0x01, 0x19, 0xA0, 0x01, 0x1B, 0xC0, 0x01, 0x1D, 0xE0, 0x01, 0x1F, 0x00, 0x02,
|
||||
0x21, 0x20, 0x02, 0x23, 0x40, 0x02, 0x25, 0x60, 0x02, 0x27, 0x80, 0x02, 0x29, 0xA0, 0x02, 0x2B,
|
||||
0xC0, 0x02, 0x2D, 0xE0, 0x02, 0x2F, 0x00, 0x03, 0x31, 0x20, 0x03, 0x33, 0x40, 0x03, 0x35, 0x60,
|
||||
0x03, 0x37, 0x80, 0x03, 0x39, 0xA0, 0x03, 0x3B, 0xC0, 0x03, 0x3D, 0xE0, 0x03, 0x3F, 0x00, 0x04,
|
||||
0x41, 0x20, 0x04, 0x43, 0x40, 0x04, 0x45, 0x60, 0x04, 0x47, 0x80, 0x04, 0x49, 0xA0, 0x04, 0x4B,
|
||||
0xC0, 0x04, 0x4D, 0xE0, 0x04, 0x4F, 0x00, 0x05, 0x51, 0x20, 0x05, 0x53, 0x40, 0x05, 0x55, 0x60,
|
||||
0x05, 0x57, 0x80, 0x05, 0x59, 0xA0, 0x05, 0x5B, 0xC0, 0x05, 0x5D, 0xE0, 0x05, 0x5F, 0x00, 0x06,
|
||||
0x61, 0x20, 0x06, 0x63, 0x40, 0x06, 0x65, 0x60, 0x06, 0x67, 0x80, 0x06, 0x69, 0xA0, 0x06, 0x6B,
|
||||
0xC0, 0x06, 0x6D, 0xE0, 0x06, 0x6F, 0x00, 0x07, 0x71, 0x20, 0x07, 0x73, 0x40, 0x07, 0x75, 0x60,
|
||||
0x07, 0x77, 0x80, 0x07, 0x79, 0xA0, 0x07, 0x7B, 0xC0, 0x07, 0x7D, 0xE0, 0x07, 0x7F, 0x00, 0x08,
|
||||
0x81, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xF8, 0xFF, 0xFF, 0x03, 0x40, 0x00, 0x05, 0x60, 0x00, 0x07, 0x80, 0x00, 0x09, 0xA0, 0x00, 0x0B,
|
||||
0xC0, 0x00, 0x0D, 0xE0, 0x00, 0x0F, 0x00, 0x01, 0x11, 0xF0, 0xFF, 0x13, 0x40, 0x01, 0x15, 0x60,
|
||||
0x01, 0x17, 0x80, 0x01, 0x19, 0xA0, 0x01, 0x1B, 0xC0, 0x01, 0x1D, 0xE0, 0x01, 0x1F, 0x00, 0x02,
|
||||
0x21, 0x20, 0x02, 0x23, 0x40, 0x02, 0x25, 0x60, 0x02, 0x27, 0x80, 0x02, 0x29, 0xA0, 0x02, 0x2B,
|
||||
0xC0, 0x02, 0x2D, 0xE0, 0x02, 0x2F, 0x00, 0x03, 0x31, 0x20, 0x03, 0x33, 0x40, 0x03, 0x35, 0x60,
|
||||
0x03, 0x37, 0x80, 0x03, 0x39, 0xA0, 0x03, 0x3B, 0xC0, 0x03, 0x3D, 0xE0, 0x03, 0x3F, 0x00, 0x04,
|
||||
0x41, 0x20, 0x04, 0x43, 0x40, 0x04, 0x45, 0x60, 0x04, 0x47, 0x80, 0x04, 0x49, 0xA0, 0x04, 0x4B,
|
||||
0xC0, 0x04, 0x4D, 0xE0, 0x04, 0x4F, 0x00, 0x05, 0x51, 0x20, 0x05, 0x53, 0x40, 0x05, 0x55, 0x60,
|
||||
0x05, 0x57, 0x80, 0x05, 0x59, 0xA0, 0x05, 0x5B, 0xC0, 0x05, 0x5D, 0xE0, 0x05, 0x5F, 0x00, 0x06,
|
||||
0x61, 0x20, 0x06, 0x63, 0x40, 0x06, 0x65, 0x60, 0x06, 0x67, 0x80, 0x06, 0x69, 0xA0, 0x06, 0x6B,
|
||||
0xC0, 0x06, 0x6D, 0xE0, 0x06, 0x6F, 0x00, 0x07, 0x71, 0x20, 0x07, 0x73, 0x40, 0x07, 0x75, 0x60,
|
||||
0x07, 0x77, 0x80, 0x07, 0x79, 0xA0, 0x07, 0x7B, 0xC0, 0x07, 0x7D, 0xE0, 0x07, 0x7F, 0x00, 0x08,
|
||||
0x81, 0x20, 0x08, 0x83, 0x40, 0x08, 0x85, 0x60, 0x08, 0x87, 0x80, 0x08, 0x89, 0xA0, 0x08, 0x8B,
|
||||
0xC0, 0x08, 0x8D, 0xE0, 0x08, 0x8F, 0x00, 0x09, 0x91, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
#else
|
||||
const char g_FAT[BLOCKSIZE] =
|
||||
{
|
||||
0xF8, 0xFF, 0xFF, 0x03, 0x40, 0x00, 0x05, 0x60, 0x00, 0x07, 0x80, 0x00, 0x09, 0xA0, 0x00, 0x0B,
|
||||
0xC0, 0x00, 0x0D, 0xE0, 0x00, 0x0F, 0x00, 0x01, 0x11, 0x20, 0x01, 0x13, 0x40, 0x01, 0x15, 0x60,
|
||||
0x01, 0x17, 0x80, 0x01, 0x19, 0xA0, 0x01, 0x1B, 0xC0, 0x01, 0x1D, 0xE0, 0x01, 0x1F, 0x00, 0x02,
|
||||
0x21, 0x20, 0x02, 0x23, 0x40, 0x02, 0x25, 0x60, 0x02, 0x27, 0x80, 0x02, 0x29, 0xA0, 0x02, 0x2B,
|
||||
0xC0, 0x02, 0x2D, 0xE0, 0x02, 0x2F, 0x00, 0x03, 0x31, 0x20, 0x03, 0x33, 0x40, 0x03, 0x35, 0x60,
|
||||
0x03, 0x37, 0x80, 0x03, 0x39, 0xA0, 0x03, 0x3B, 0xC0, 0x03, 0x3D, 0xE0, 0x03, 0x3F, 0x00, 0x04,
|
||||
0x41, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0xF8, 0xFF, 0xFF, 0x03, 0x40, 0x00, 0x05, 0x60, 0x00, 0x07, 0x80, 0x00, 0x09, 0xF0, 0xFF, 0x0B,
|
||||
0xC0, 0x00, 0x0D, 0xE0, 0x00, 0x0F, 0x00, 0x01, 0x11, 0x20, 0x01, 0x13, 0x40, 0x01, 0x15, 0x60,
|
||||
0x01, 0x17, 0x80, 0x01, 0x19, 0xA0, 0x01, 0x1B, 0xC0, 0x01, 0x1D, 0xE0, 0x01, 0x1F, 0x00, 0x02,
|
||||
0x21, 0x20, 0x02, 0x23, 0x40, 0x02, 0x25, 0x60, 0x02, 0x27, 0x80, 0x02, 0x29, 0xA0, 0x02, 0x2B,
|
||||
0xC0, 0x02, 0x2D, 0xE0, 0x02, 0x2F, 0x00, 0x03, 0x31, 0x20, 0x03, 0x33, 0x40, 0x03, 0x35, 0x60,
|
||||
0x03, 0x37, 0x80, 0x03, 0x39, 0xA0, 0x03, 0x3B, 0xC0, 0x03, 0x3D, 0xE0, 0x03, 0x3F, 0x00, 0x04,
|
||||
0x41, 0x20, 0x04, 0x43, 0x40, 0x04, 0x45, 0x60, 0x04, 0x47, 0x80, 0x04, 0x49, 0xA0, 0x04, 0x4B,
|
||||
0xC0, 0x04, 0x4D, 0xE0, 0x04, 0x4F, 0x00, 0x05, 0x51, 0x20, 0x05, 0x53, 0x40, 0x05, 0x55, 0x60,
|
||||
0x05, 0x57, 0x80, 0x05, 0x59, 0xA0, 0x05, 0x5B, 0xC0, 0x05, 0x5D, 0xE0, 0x05, 0x5F, 0x00, 0x06,
|
||||
0x61, 0x20, 0x06, 0x63, 0x40, 0x06, 0x65, 0x60, 0x06, 0x67, 0x80, 0x06, 0x69, 0xA0, 0x06, 0x6B,
|
||||
0xC0, 0x06, 0x6D, 0xE0, 0x06, 0x6F, 0x00, 0x07, 0x71, 0x20, 0x07, 0x73, 0x40, 0x07, 0x75, 0x60,
|
||||
0x07, 0x77, 0x80, 0x07, 0x79, 0xA0, 0x07, 0x7B, 0xC0, 0x07, 0x7D, 0xE0, 0x07, 0x7F, 0x00, 0x08,
|
||||
0x81, 0x20, 0x08, 0x83, 0x40, 0x08, 0x85, 0x60, 0x08, 0x87, 0x80, 0x08, 0x89, 0xF0, 0xFF, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -442,7 +455,7 @@ const FATDirEntry_t g_DIRroot[16] =
|
||||
0x00000000
|
||||
},
|
||||
{
|
||||
{ 'T', 'A', 'R', 'A', 'N', 'I', 'S', ' '},
|
||||
{ 'E', 'E', 'P', 'R', 'O', 'M', ' ', ' '},
|
||||
{ 'B', 'I', 'N'},
|
||||
0x24, // Archive, hidden, system
|
||||
0x00,
|
||||
@@ -457,19 +470,19 @@ const FATDirEntry_t g_DIRroot[16] =
|
||||
EESIZE
|
||||
},
|
||||
{
|
||||
{ '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||
{ ' ', ' ', ' '},
|
||||
0x00,
|
||||
0x00,
|
||||
{ 'F', 'I', 'R', 'M', 'W', 'A', 'R', 'E'},
|
||||
{ 'B', 'I', 'N'},
|
||||
0x24, // Archive, hidden, system
|
||||
0x00,
|
||||
0x3E,
|
||||
0xA301,
|
||||
0x3D55,
|
||||
0x3D55,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x00000000
|
||||
0xA302,
|
||||
0x3D55,
|
||||
0x0002 + (EESIZE/BLOCKSIZE)/8,
|
||||
FLASHSIZE
|
||||
},
|
||||
{
|
||||
{ '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||
@@ -674,17 +687,24 @@ int32_t fat12Read( uint8_t *buffer, uint16_t sector, uint16_t count )
|
||||
while ( count )
|
||||
{
|
||||
if (sector == 0) {
|
||||
memcpy( buffer, g_FATboot, BLOCKSIZE ) ;
|
||||
memcpy(buffer, g_FATboot, BLOCKSIZE ) ;
|
||||
}
|
||||
else if (sector == 1/*Reserved sector count*/) {
|
||||
// FAT table.
|
||||
memcpy( buffer, g_FAT, BLOCKSIZE);
|
||||
memcpy(buffer, g_FAT, BLOCKSIZE);
|
||||
}
|
||||
else if (sector == 2) {
|
||||
memcpy( buffer, g_DIRroot, BLOCKSIZE ) ;
|
||||
memcpy(buffer, g_DIRroot, BLOCKSIZE ) ;
|
||||
}
|
||||
else {
|
||||
eeprom_read_block (buffer, (sector-3)*BLOCKSIZE, BLOCKSIZE);
|
||||
else if (sector < 3 + (EESIZE/BLOCKSIZE)) {
|
||||
eeprom_read_block(buffer, (sector-3)*BLOCKSIZE, BLOCKSIZE);
|
||||
}
|
||||
else if (sector < 3 + (EESIZE/BLOCKSIZE) + (FLASHSIZE/BLOCKSIZE)) {
|
||||
uint32_t address;
|
||||
address = sector - 3 - (EESIZE/BLOCKSIZE);
|
||||
address *= BLOCKSIZE;
|
||||
address += FIRMWARE_ADDRESS;
|
||||
memcpy(buffer, (uint8_t *)address, BLOCKSIZE);
|
||||
}
|
||||
buffer += BLOCKSIZE ;
|
||||
sector++ ;
|
||||
@@ -692,35 +712,59 @@ int32_t fat12Read( uint8_t *buffer, uint16_t sector, uint16_t count )
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint32_t count )
|
||||
{
|
||||
static int offset = 0;
|
||||
static uint8_t eepromOffset = 0;
|
||||
static uint8_t firmwareAllowed = 0;
|
||||
|
||||
TRACE("FAT12 Write(sector=%d, count=%d)", sector, count);
|
||||
|
||||
while (count) {
|
||||
const EeFs * test = (const EeFs *)buffer;
|
||||
if (offset == 0 && test->version==EEFS_VERS && test->mySize==sizeof(eeFs) && test->bs==BS) {
|
||||
TRACE("EEPROM start found in sector %d", sector);
|
||||
offset = sector;
|
||||
if (sector < 3) {
|
||||
// reserved, read-only
|
||||
}
|
||||
else if (sector < 3 + (EESIZE/BLOCKSIZE)) {
|
||||
while (count) {
|
||||
if (eepromOffset == 0 && isEepromStart(buffer)) {
|
||||
TRACE("EEPROM start found in sector %d", sector);
|
||||
eepromOffset = sector;
|
||||
}
|
||||
if (eepromOffset && sector >= eepromOffset && (sector-eepromOffset) < EESIZE/BLOCKSIZE) {
|
||||
eeWriteBlockCmp((uint8_t *)buffer, (sector-eepromOffset)*BLOCKSIZE, BLOCKSIZE);
|
||||
}
|
||||
buffer += BLOCKSIZE;
|
||||
sector++;
|
||||
count--;
|
||||
if (sector-eepromOffset >= EESIZE/BLOCKSIZE) {
|
||||
TRACE("EEPROM end written at sector %d", sector-1);
|
||||
eepromOffset = 0;
|
||||
}
|
||||
}
|
||||
if (offset && sector >= offset && (sector-offset) < EESIZE/BLOCKSIZE) {
|
||||
eeWriteBlockCmp((uint8_t *)buffer, (sector-offset)*BLOCKSIZE, BLOCKSIZE);
|
||||
}
|
||||
buffer += BLOCKSIZE;
|
||||
sector++;
|
||||
count--;
|
||||
if (sector-offset >= EESIZE/BLOCKSIZE) {
|
||||
TRACE("EEPROM end written at sector %d", sector-1);
|
||||
offset = 0;
|
||||
}
|
||||
else if (sector < 3 + (EESIZE/BLOCKSIZE) + (FLASHSIZE/BLOCKSIZE)) {
|
||||
// firmware
|
||||
uint32_t address;
|
||||
address = sector - 3 - (EESIZE/BLOCKSIZE);
|
||||
address *= BLOCKSIZE;
|
||||
address += FIRMWARE_ADDRESS;
|
||||
|
||||
while (count) {
|
||||
for (uint32_t i=0; i<BLOCKSIZE/FLASH_PAGESIZE; i++) {
|
||||
if (address >= FIRMWARE_ADDRESS+BOOTLOADER_SIZE/*protect bootloader*/ && address <= FIRMWARE_ADDRESS+FLASHSIZE-FLASH_PAGESIZE) {
|
||||
if (address == FIRMWARE_ADDRESS+BOOTLOADER_SIZE) {
|
||||
firmwareAllowed = isFirmwareStart(buffer);
|
||||
}
|
||||
if (firmwareAllowed) {
|
||||
writeFlash((uint32_t *)address, (uint32_t *)buffer);
|
||||
}
|
||||
}
|
||||
address += FLASH_PAGESIZE;
|
||||
buffer += FLASH_PAGESIZE;
|
||||
}
|
||||
count--;
|
||||
}
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "../opentx.h"
|
||||
#include "../../opentx.h"
|
||||
|
||||
extern "C" {
|
||||
#include "usbd_usr.h"
|
||||
@@ -119,7 +119,6 @@ void USBD_USR_DeviceConnected (void)
|
||||
*/
|
||||
void USBD_USR_DeviceDisconnected (void)
|
||||
{
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user