1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 16:55:20 +03:00

Cosmetics

This commit is contained in:
Bertrand Songis 2016-03-01 19:45:24 +01:00
parent d6c7b63f90
commit 638648a0a4
2 changed files with 54 additions and 54 deletions

View file

@ -2,7 +2,7 @@
* Copyright (C) OpenTX * Copyright (C) OpenTX
* *
* Based on code named * Based on code named
* th9x - http://code.google.com/p/th9x * th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x * er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x * gruvin9x - http://code.google.com/p/gruvin9x
* *
@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "../opentx.h" #include "opentx.h"
void getModelPath(char * path, const char * filename) void getModelPath(char * path, const char * filename)
{ {

View file

@ -2,7 +2,7 @@
* Copyright (C) OpenTX * Copyright (C) OpenTX
* *
* Based on code named * Based on code named
* th9x - http://code.google.com/p/th9x * th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x * er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x * gruvin9x - http://code.google.com/p/gruvin9x
* *
@ -25,8 +25,8 @@
/* are platform dependent. */ /* are platform dependent. */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
#include "../opentx.h" #include "opentx.h"
#include "../FatFs/diskio.h" #include "diskio.h"
/* Definitions for MMC/SDC command */ /* Definitions for MMC/SDC command */
#define CMD0 (0) /* GO_IDLE_STATE */ #define CMD0 (0) /* GO_IDLE_STATE */
@ -73,9 +73,9 @@
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
Module Private Functions Module Private Functions
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
static volatile static volatile
@ -145,7 +145,7 @@ int wait_ready (void) /* 1:OK, 0:Timeout */
do do
if (rcvr_spi() == 0xFF) return 1; if (rcvr_spi() == 0xFF) return 1;
while (Timer2); while (Timer2);
return 0; return 0;
} }
@ -203,7 +203,7 @@ void power_on (void)
#endif #endif
//PORTB = 0b10110101; // Enable drivers //PORTB = 0b10110101; // Enable drivers
//DDRB = 0b11000111; //DDRB = 0b11000111;
SPCR = 0x52; // Enable SPI function in mode 0 SPCR = 0x52; // Enable SPI function in mode 0
SPSR = 0x00; // G: was 0x01; // SPI 2x mode SPSR = 0x00; // G: was 0x01; // SPI 2x mode
} }
@ -215,7 +215,7 @@ void power_off (void)
SPCR = 0; /* Disable SPI function */ SPCR = 0; /* Disable SPI function */
// DDRB = 0b11000000; /* Disable drivers */ // DDRB = 0b11000000; /* Disable drivers */
// PORTB = 0b10110000; // PORTB = 0b10110000;
// PORTE |= 0x80; /* Socket power off */ // PORTE |= 0x80; /* Socket power off */
Stat |= STA_NOINIT; Stat |= STA_NOINIT;
} }
@ -233,14 +233,14 @@ int rcvr_datablock (
) )
{ {
BYTE token; BYTE token;
Timer1 = 20; Timer1 = 20;
do { /* Wait for data packet in timeout of 200ms */ do { /* Wait for data packet in timeout of 200ms */
token = rcvr_spi(); token = rcvr_spi();
} while ((token == 0xFF) && Timer1); } while ((token == 0xFF) && Timer1);
if(token != 0xFE) return 0; /* If not valid data token, retutn with error */ if(token != 0xFE) return 0; /* If not valid data token, retutn with error */
do { /* Receive the data block into buffer */ do { /* Receive the data block into buffer */
rcvr_spi_m(buff++); rcvr_spi_m(buff++);
rcvr_spi_m(buff++); rcvr_spi_m(buff++);
@ -249,7 +249,7 @@ int rcvr_datablock (
} while (btr -= 4); } while (btr -= 4);
rcvr_spi(); /* Discard CRC */ rcvr_spi(); /* Discard CRC */
rcvr_spi(); rcvr_spi();
return 1; /* Return with success */ return 1; /* Return with success */
} }
@ -266,10 +266,10 @@ int xmit_datablock (
) )
{ {
BYTE resp, wc; BYTE resp, wc;
if (!wait_ready()) return 0; if (!wait_ready()) return 0;
xmit_spi(token); /* Xmit data token */ xmit_spi(token); /* Xmit data token */
if (token != 0xFD) { /* Is data token */ if (token != 0xFD) { /* Is data token */
wc = 0; wc = 0;
@ -283,7 +283,7 @@ int xmit_datablock (
if ((resp & 0x1F) != 0x05) /* If not accepted, return with error */ if ((resp & 0x1F) != 0x05) /* If not accepted, return with error */
return 0; return 0;
} }
return 1; return 1;
} }
@ -300,18 +300,18 @@ BYTE send_cmd ( /* Returns R1 resp (bit7==1:Send failed) */
) )
{ {
BYTE n, res; BYTE n, res;
if (cmd & 0x80) { /* ACMD<n> is the command sequense of CMD55-CMD<n> */ if (cmd & 0x80) { /* ACMD<n> is the command sequense of CMD55-CMD<n> */
cmd &= 0x7F; cmd &= 0x7F;
res = send_cmd(CMD55, 0); res = send_cmd(CMD55, 0);
if (res > 1) return res; if (res > 1) return res;
} }
/* Select the card and wait for ready */ /* Select the card and wait for ready */
deselect(); deselect();
if (!select()) return 0xFF; if (!select()) return 0xFF;
/* Send command packet */ /* Send command packet */
xmit_spi(0x40 | cmd); /* Start + Command index */ xmit_spi(0x40 | cmd); /* Start + Command index */
xmit_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ xmit_spi((BYTE)(arg >> 24)); /* Argument[31..24] */
@ -322,23 +322,23 @@ BYTE send_cmd ( /* Returns R1 resp (bit7==1:Send failed) */
if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) */ if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) */
if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) */ if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) */
xmit_spi(n); xmit_spi(n);
/* Receive command response */ /* Receive command response */
if (cmd == CMD12) rcvr_spi(); /* Skip a stuff byte when stop reading */ if (cmd == CMD12) rcvr_spi(); /* Skip a stuff byte when stop reading */
n = 10; /* Wait for a valid response in timeout of 10 attempts */ n = 10; /* Wait for a valid response in timeout of 10 attempts */
do do
res = rcvr_spi(); res = rcvr_spi();
while ((res & 0x80) && --n); while ((res & 0x80) && --n);
return res; /* Return with the response value */ return res; /* Return with the response value */
} }
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
Public Functions Public Functions
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
@ -351,15 +351,15 @@ DSTATUS disk_initialize (
) )
{ {
BYTE n, cmd, ty, ocr[4]; BYTE n, cmd, ty, ocr[4];
if (drv) return STA_NOINIT; /* Supports only single drive */ if (drv) return STA_NOINIT; /* Supports only single drive */
if (Stat & STA_NODISK) return Stat; /* No card in the socket */ if (Stat & STA_NODISK) return Stat; /* No card in the socket */
power_on(); /* Force socket power on */ power_on(); /* Force socket power on */
FCLK_SLOW(); FCLK_SLOW();
for (n = 10; n; n--) rcvr_spi(); /* 80 dummy clocks */ for (n = 10; n; n--) rcvr_spi(); /* 80 dummy clocks */
ty = 0; ty = 0;
if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */
Timer1 = 100; /* Initialization timeout of 1000 msec */ Timer1 = 100; /* Initialization timeout of 1000 msec */
@ -385,14 +385,14 @@ DSTATUS disk_initialize (
} }
CardType = ty; CardType = ty;
deselect(); deselect();
if (ty) { /* Initialization succeded */ if (ty) { /* Initialization succeded */
Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */
FCLK_FAST(); FCLK_FAST();
} else { /* Initialization failed */ } else { /* Initialization failed */
power_off(); power_off();
} }
return Stat; return Stat;
} }
@ -425,9 +425,9 @@ DRESULT disk_read (
{ {
if (drv || !count) return RES_PARERR; if (drv || !count) return RES_PARERR;
if (Stat & STA_NOINIT) return RES_NOTRDY; if (Stat & STA_NOINIT) return RES_NOTRDY;
if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */
if (count == 1) { /* Single block read */ if (count == 1) { /* Single block read */
if ((send_cmd(CMD17, sector) == 0) /* READ_SINGLE_BLOCK */ if ((send_cmd(CMD17, sector) == 0) /* READ_SINGLE_BLOCK */
&& rcvr_datablock(buff, 512)) && rcvr_datablock(buff, 512))
@ -443,7 +443,7 @@ DRESULT disk_read (
} }
} }
deselect(); deselect();
return count ? RES_ERROR : RES_OK; return count ? RES_ERROR : RES_OK;
} }
@ -463,9 +463,9 @@ DRESULT disk_write (
if (drv || !count) return RES_PARERR; if (drv || !count) return RES_PARERR;
if (Stat & STA_NOINIT) return RES_NOTRDY; if (Stat & STA_NOINIT) return RES_NOTRDY;
if (Stat & STA_PROTECT) return RES_WRPRT; if (Stat & STA_PROTECT) return RES_WRPRT;
if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */
if (count == 1) { /* Single block write */ if (count == 1) { /* Single block write */
if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */
&& xmit_datablock(buff, 0xFE)) && xmit_datablock(buff, 0xFE))
@ -483,7 +483,7 @@ DRESULT disk_write (
} }
} }
deselect(); deselect();
return count ? RES_ERROR : RES_OK; return count ? RES_ERROR : RES_OK;
} }
@ -502,12 +502,12 @@ DRESULT disk_ioctl (
DRESULT res; DRESULT res;
BYTE n, csd[16], *ptr = (BYTE*)buff; BYTE n, csd[16], *ptr = (BYTE*)buff;
WORD csize; WORD csize;
if (drv) return RES_PARERR; if (drv) return RES_PARERR;
res = RES_ERROR; res = RES_ERROR;
if (ctrl == CTRL_POWER) { if (ctrl == CTRL_POWER) {
switch (ptr[0]) { switch (ptr[0]) {
case 0: /* Sub control code (POWER_OFF) */ case 0: /* Sub control code (POWER_OFF) */
@ -524,7 +524,7 @@ DRESULT disk_ioctl (
} }
else { else {
if (Stat & STA_NOINIT) return RES_NOTRDY; if (Stat & STA_NOINIT) return RES_NOTRDY;
switch (ctrl) { switch (ctrl) {
case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */
if (select()) { if (select()) {
@ -532,7 +532,7 @@ DRESULT disk_ioctl (
res = RES_OK; res = RES_OK;
} }
break; break;
case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) {
if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */
@ -546,12 +546,12 @@ DRESULT disk_ioctl (
res = RES_OK; res = RES_OK;
} }
break; break;
case GET_SECTOR_SIZE : /* Get R/W sector size (WORD) */ case GET_SECTOR_SIZE : /* Get R/W sector size (WORD) */
*(WORD*)buff = 512; *(WORD*)buff = 512;
res = RES_OK; res = RES_OK;
break; break;
case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */
if (CardType & CT_SD2) { /* SDv2? */ if (CardType & CT_SD2) { /* SDv2? */
if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */
@ -573,31 +573,31 @@ DRESULT disk_ioctl (
} }
} }
break; break;
case MMC_GET_TYPE : /* Get card type flags (1 byte) */ case MMC_GET_TYPE : /* Get card type flags (1 byte) */
*ptr = CardType; *ptr = CardType;
res = RES_OK; res = RES_OK;
break; break;
case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */
if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ if (send_cmd(CMD9, 0) == 0 /* READ_CSD */
&& rcvr_datablock(ptr, 16)) && rcvr_datablock(ptr, 16))
res = RES_OK; res = RES_OK;
break; break;
case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */
if (send_cmd(CMD10, 0) == 0 /* READ_CID */ if (send_cmd(CMD10, 0) == 0 /* READ_CID */
&& rcvr_datablock(ptr, 16)) && rcvr_datablock(ptr, 16))
res = RES_OK; res = RES_OK;
break; break;
case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */
if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */
for (n = 4; n; n--) *ptr++ = rcvr_spi(); for (n = 4; n; n--) *ptr++ = rcvr_spi();
res = RES_OK; res = RES_OK;
} }
break; break;
case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */
if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */
rcvr_spi(); rcvr_spi();
@ -605,14 +605,14 @@ DRESULT disk_ioctl (
res = RES_OK; res = RES_OK;
} }
break; break;
default: default:
res = RES_PARERR; res = RES_PARERR;
} }
deselect(); deselect();
} }
return res; return res;
} }