Merge branch 'main' into fast-scroll

This commit is contained in:
pweingar 2025-01-04 15:27:31 -05:00 committed by GitHub
commit 9b7dab7c2a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 8 deletions

View file

@ -7,11 +7,8 @@
*/ */
#include "log_level.h" #include "log_level.h"
#ifdef DEFAULT_LOG_LEVEL
//#undef DEFAULT_LOG_LEVEL
#endif
#ifndef DEFAULT_LOG_LEVEL #ifndef DEFAULT_LOG_LEVEL
#define DEFAULT_LOG_LEVEL LOG_TRACE #define DEFAULT_LOG_LEVEL LOG_ERROR
#endif #endif
#include <string.h> #include <string.h>

View file

@ -23,6 +23,7 @@
#include "interrupt.h" #include "interrupt.h"
#include "F256/sdc_spi.h" #include "F256/sdc_spi.h"
#include "sdc_f256.h" #include "sdc_f256.h"
#include "utilities.h"
/* MMC/SD command (SPI mode) */ /* MMC/SD command (SPI mode) */
#define CMD0 (0) /* GO_IDLE_STATE */ #define CMD0 (0) /* GO_IDLE_STATE */
@ -379,7 +380,7 @@ static short sdc_read(p_dev_block dev, long lba, uint8_t * buffer, short size) {
p_sd_card_info card = (p_sd_card_info)dev->data; p_sd_card_info card = (p_sd_card_info)dev->data;
p_sdc_spi sd = card->reg; p_sdc_spi sd = card->reg;
uint8_t cmd; uint8_t cmd;
short count = size % 512 + 1; short count = ceil_div_short(size, 512);
if (card->status & SDC_STAT_NOINIT) { if (card->status & SDC_STAT_NOINIT) {
return ERR_NOT_READY; return ERR_NOT_READY;
@ -420,7 +421,7 @@ static short sdc_write(p_dev_block dev, long lba, const uint8_t * buffer, short
p_sd_card_info card = (p_sd_card_info)dev->data; p_sd_card_info card = (p_sd_card_info)dev->data;
p_sdc_spi sd = card->reg; p_sdc_spi sd = card->reg;
uint8_t cmd; uint8_t cmd;
short count = size % 512 + 1; short count = ceil_div_short(size, 512);
if (card->status & SDC_STAT_NOINIT) { if (card->status & SDC_STAT_NOINIT) {
return ERR_NOT_READY; return ERR_NOT_READY;

View file

@ -3,8 +3,8 @@
*/ */
#include "log_level.h" #include "log_level.h"
#define DEFAULT_LOG_LEVEL LOG_INFO #define DEFAULT_LOG_LEVEL LOG_ERROR
#define LOG_CHANNEL LOG_CHANNEL_UART0 #define LOG_CHANNEL LOG_CHANNEL_CHANNEL_A
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>

View file

@ -7,6 +7,16 @@
#include <ctype.h> #include <ctype.h>
#include "utilities.h" #include "utilities.h"
/**
* Return the ceiling of a/b using only short operations
*
* @param a the numerator
* @param b the denominator
* @return the smallest short c such that c >= a / b
*/
short ceil_div_short(short a, short b) {
return (a + (b - 1)) / b;
}
/** /**
* Re-entrant version of strtok_r, because VBCC does not provide it * Re-entrant version of strtok_r, because VBCC does not provide it

View file

@ -13,6 +13,15 @@
/** Return the maximum value of x or y */ /** Return the maximum value of x or y */
#define max(x, y) ((x < y) ? y : x) #define max(x, y) ((x < y) ? y : x)
/**
* Return the ceiling of a/b using only short operations
*
* @param a the numerator
* @param b the denominator
* @return the smallest short c such that c >= a / b
*/
extern short ceil_div_short(short a, short b);
/** /**
* Re-entrant version of strtok_r, because VBCC does not provide it * Re-entrant version of strtok_r, because VBCC does not provide it
* *