Tweaky cleanup, no fixes
This commit is contained in:
parent
fdb698936e
commit
d814f97fe5
1 changed files with 52 additions and 59 deletions
|
|
@ -44,7 +44,8 @@ extern "C" void u8g_10MicroDelay() {
|
||||||
extern "C" void u8g_Delay(uint16_t val) {
|
extern "C" void u8g_Delay(uint16_t val) {
|
||||||
delay(val);
|
delay(val);
|
||||||
}
|
}
|
||||||
//************************//
|
|
||||||
|
//************************
|
||||||
|
|
||||||
// return free heap space
|
// return free heap space
|
||||||
int freeMemory() {
|
int freeMemory() {
|
||||||
|
|
@ -57,9 +58,9 @@ int freeMemory() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// scan command line for code
|
// Scan command line for code
|
||||||
// return index into pin map array if found and the pin is valid.
|
// Return index into pin map array if found and the pin is valid.
|
||||||
// return dval if not found or not a valid pin.
|
// Return dval if not found or not a valid pin.
|
||||||
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
|
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
|
||||||
const uint16_t val = (uint16_t)parser.intval(code, -1), port = val / 100, pin = val % 100;
|
const uint16_t val = (uint16_t)parser.intval(code, -1), port = val / 100, pin = val % 100;
|
||||||
const int16_t ind = (port < ((NUM_DIGITAL_PINS) >> 5) && pin < 32) ? ((port << 5) | pin) : -2;
|
const int16_t ind = (port < ((NUM_DIGITAL_PINS) >> 5) && pin < 32) ? ((port << 5) | pin) : -2;
|
||||||
|
|
@ -86,12 +87,11 @@ uint8_t HAL_get_reset_source(void) {
|
||||||
#include "../../sd/cardreader.h"
|
#include "../../sd/cardreader.h"
|
||||||
|
|
||||||
DRESULT disk_read (
|
DRESULT disk_read (
|
||||||
BYTE drv, /* Physical drive number (0) */
|
BYTE drv, // Physical drive number (0)
|
||||||
BYTE *buff, /* Pointer to the data buffer to store read data */
|
BYTE *buff, // Pointer to the data buffer to store read data
|
||||||
DWORD sector, /* Start sector number (LBA) */
|
DWORD sector, // Start sector number (LBA)
|
||||||
UINT count /* Number of sectors to read (1..128) */
|
UINT count // Number of sectors to read (1..128)
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
auto sd2card = card.getSd2Card();
|
auto sd2card = card.getSd2Card();
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
sd2card.readBlock(sector, buff);
|
sd2card.readBlock(sector, buff);
|
||||||
|
|
@ -107,21 +107,13 @@ DRESULT disk_read (
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
DSTATUS disk_status (
|
DSTATUS disk_status(BYTE drv) { // Physical drive number (0)
|
||||||
BYTE drv /* Physical drive number (0) */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DSTATUS disk_initialize (
|
DSTATUS disk_initialize(BYTE drv) { // Physical drive number (0)
|
||||||
BYTE drv /* Physical drive number (0) */
|
// If already mounted, it's already initialized!
|
||||||
) {
|
if (!card.isMounted()) {
|
||||||
//if already mounted, its already initialized!
|
|
||||||
if (card.isMounted()) {
|
|
||||||
return RES_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto sd2card = card.getSd2Card();
|
auto sd2card = card.getSd2Card();
|
||||||
if (!sd2card.init(SPI_SPEED, SDSS)
|
if (!sd2card.init(SPI_SPEED, SDSS)
|
||||||
#if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
|
#if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
|
||||||
|
|
@ -130,18 +122,19 @@ DSTATUS disk_initialize (
|
||||||
) {
|
) {
|
||||||
return RES_ERROR;
|
return RES_ERROR;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if _DISKIO_WRITE
|
#if _DISKIO_WRITE
|
||||||
DRESULT disk_write (
|
|
||||||
BYTE drv, /* Physical drive number (0) */
|
DRESULT disk_write(
|
||||||
const BYTE *buff, /* Ponter to the data to write */
|
BYTE drv, // Physical drive number (0)
|
||||||
DWORD sector, /* Start sector number (LBA) */
|
const BYTE *buff, // Ponter to the data to write
|
||||||
UINT count /* Number of sectors to write (1..128) */
|
DWORD sector, // Start sector number (LBA)
|
||||||
)
|
UINT count // Number of sectors to write (1..128)
|
||||||
{
|
) {
|
||||||
auto sd2card = card.getSd2Card();
|
auto sd2card = card.getSd2Card();
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
sd2card.writeBlock(sector, buff);
|
sd2card.writeBlock(sector, buff);
|
||||||
|
|
@ -157,35 +150,35 @@ DSTATUS disk_initialize (
|
||||||
sd2card.writeStop();
|
sd2card.writeStop();
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _DISKIO_WRITE
|
#endif // _DISKIO_WRITE
|
||||||
|
|
||||||
#if _DISKIO_IOCTL
|
#if _DISKIO_IOCTL
|
||||||
|
|
||||||
DRESULT disk_ioctl (
|
DRESULT disk_ioctl(
|
||||||
BYTE drv, /* Physical drive number (0) */
|
BYTE drv, // Physical drive number (0)
|
||||||
BYTE cmd, /* Control command code */
|
BYTE cmd, // Control command code
|
||||||
void *buff /* Pointer to the conrtol data */
|
void *buff // Pointer to the conrtol data
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
DWORD *dp, st, ed;
|
DWORD *dp, st, ed;
|
||||||
|
|
||||||
auto sd2card = card.getSd2Card();
|
auto sd2card = card.getSd2Card();
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case CTRL_SYNC: /* Wait for end of internal write process of the drive */
|
case CTRL_SYNC: // Wait for end of internal write process of the drive
|
||||||
break;
|
break;
|
||||||
case GET_SECTOR_COUNT: /* Get drive capacity in unit of sector (DWORD) */
|
case GET_SECTOR_COUNT: // Get drive capacity in unit of sector (DWORD)
|
||||||
*(int32_t*)buff = sd2card.cardSize();
|
*(int32_t*)buff = sd2card.cardSize();
|
||||||
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)
|
||||||
break;
|
break;
|
||||||
case CTRL_TRIM: /* Erase a block of sectors (used when _USE_TRIM in ffconf.h is 1) */
|
case CTRL_TRIM: // Erase a block of sectors (used when _USE_TRIM in ffconf.h is 1)
|
||||||
dp = (DWORD*)buff; st = dp[0]; ed = dp[1]; /* Load sector block */
|
dp = (DWORD*)buff; st = dp[0]; ed = dp[1]; // Load sector block
|
||||||
sd2card.erase(st, ed);
|
sd2card.erase(st, ed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _DISKIO_IOCTL
|
#endif // _DISKIO_IOCTL
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue