Clean up comments, USB flash, NULLs
This commit is contained in:
@ -84,7 +84,7 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
|
||||
card.getSd2Card().readData(sector_buf);
|
||||
|
||||
// RAM -> USB
|
||||
if (!udi_msc_trans_block(true, sector_buf, SD_MMC_BLOCK_SIZE, NULL)) {
|
||||
if (!udi_msc_trans_block(true, sector_buf, SD_MMC_BLOCK_SIZE, nullptr)) {
|
||||
card.getSd2Card().readStop();
|
||||
return CTRL_FAIL;
|
||||
}
|
||||
@ -120,7 +120,7 @@ Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
|
||||
while (nb_sector--) {
|
||||
|
||||
// USB -> RAM
|
||||
if (!udi_msc_trans_block(false, sector_buf, SD_MMC_BLOCK_SIZE, NULL)) {
|
||||
if (!udi_msc_trans_block(false, sector_buf, SD_MMC_BLOCK_SIZE, nullptr)) {
|
||||
card.getSd2Card().writeStop();
|
||||
return CTRL_FAIL;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ int i2s_init() {
|
||||
|
||||
// Allocate the array of pointers to the buffers
|
||||
dma.buffers = (uint32_t **)malloc(sizeof(uint32_t*) * DMA_BUF_COUNT);
|
||||
if (dma.buffers == nullptr) return -1;
|
||||
if (!dma.buffers) return -1;
|
||||
|
||||
// Allocate each buffer that can be used by the DMA controller
|
||||
for (int buf_idx = 0; buf_idx < DMA_BUF_COUNT; buf_idx++) {
|
||||
@ -194,7 +194,7 @@ int i2s_init() {
|
||||
|
||||
// Allocate the array of DMA descriptors
|
||||
dma.desc = (lldesc_t**) malloc(sizeof(lldesc_t*) * DMA_BUF_COUNT);
|
||||
if (dma.desc == nullptr) return -1;
|
||||
if (!dma.desc) return -1;
|
||||
|
||||
// Allocate each DMA descriptor that will be used by the DMA controller
|
||||
for (int buf_idx = 0; buf_idx < DMA_BUF_COUNT; buf_idx++) {
|
||||
|
@ -40,7 +40,7 @@ size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
|
||||
bool PersistentStore::access_start() {
|
||||
const char eeprom_erase_value = 0xFF;
|
||||
FILE * eeprom_file = fopen(filename, "rb");
|
||||
if (eeprom_file == nullptr) return false;
|
||||
if (!eeprom_file) return false;
|
||||
|
||||
fseek(eeprom_file, 0L, SEEK_END);
|
||||
std::size_t file_size = ftell(eeprom_file);
|
||||
@ -59,7 +59,7 @@ bool PersistentStore::access_start() {
|
||||
|
||||
bool PersistentStore::access_finish() {
|
||||
FILE * eeprom_file = fopen(filename, "wb");
|
||||
if (eeprom_file == nullptr) return false;
|
||||
if (!eeprom_file) return false;
|
||||
fwrite(buffer, sizeof(uint8_t), sizeof(buffer), eeprom_file);
|
||||
fclose(eeprom_file);
|
||||
return true;
|
||||
|
@ -86,10 +86,10 @@ public:
|
||||
GpioEvent::Type evt_type = value > 1 ? GpioEvent::SET_VALUE : value > pin_map[pin].value ? GpioEvent::RISE : value < pin_map[pin].value ? GpioEvent::FALL : GpioEvent::NOP;
|
||||
pin_map[pin].value = value;
|
||||
GpioEvent evt(Clock::nanos(), pin, evt_type);
|
||||
if (pin_map[pin].cb != nullptr) {
|
||||
if (pin_map[pin].cb) {
|
||||
pin_map[pin].cb->interrupt(evt);
|
||||
}
|
||||
if (Gpio::logger != nullptr) Gpio::logger->log(evt);
|
||||
if (Gpio::logger) Gpio::logger->log(evt);
|
||||
}
|
||||
|
||||
static uint16_t get(pin_type pin) {
|
||||
@ -105,8 +105,8 @@ public:
|
||||
if (!valid_pin(pin)) return;
|
||||
pin_map[pin].mode = value;
|
||||
GpioEvent evt(Clock::nanos(), pin, GpioEvent::Type::SETM);
|
||||
if (pin_map[pin].cb != nullptr) pin_map[pin].cb->interrupt(evt);
|
||||
if (Gpio::logger != nullptr) Gpio::logger->log(evt);
|
||||
if (pin_map[pin].cb) pin_map[pin].cb->interrupt(evt);
|
||||
if (Gpio::logger) Gpio::logger->log(evt);
|
||||
}
|
||||
|
||||
static uint8_t getMode(pin_type pin) {
|
||||
@ -118,8 +118,8 @@ public:
|
||||
if (!valid_pin(pin)) return;
|
||||
pin_map[pin].dir = value;
|
||||
GpioEvent evt(Clock::nanos(), pin, GpioEvent::Type::SETD);
|
||||
if (pin_map[pin].cb != nullptr) pin_map[pin].cb->interrupt(evt);
|
||||
if (Gpio::logger != nullptr) Gpio::logger->log(evt);
|
||||
if (pin_map[pin].cb) pin_map[pin].cb->interrupt(evt);
|
||||
if (Gpio::logger) Gpio::logger->log(evt);
|
||||
}
|
||||
|
||||
static uint8_t getDir(pin_type pin) {
|
||||
|
@ -300,7 +300,7 @@ uint16_t HAL_adc_result;
|
||||
DMA_ADDRESS_INCREMENT_STEP_SIZE_1, // STEPSIZE
|
||||
DMA_STEPSEL_SRC // STEPSEL
|
||||
);
|
||||
if (descriptor != nullptr)
|
||||
if (descriptor)
|
||||
descriptor->BTCTRL.bit.EVOSEL = DMA_EVENT_OUTPUT_BEAT;
|
||||
adc0DMAProgram.startJob();
|
||||
}
|
||||
@ -337,7 +337,7 @@ uint16_t HAL_adc_result;
|
||||
DMA_ADDRESS_INCREMENT_STEP_SIZE_1, // STEPSIZE
|
||||
DMA_STEPSEL_SRC // STEPSEL
|
||||
);
|
||||
if (descriptor != nullptr)
|
||||
if (descriptor)
|
||||
descriptor->BTCTRL.bit.EVOSEL = DMA_EVENT_OUTPUT_BEAT;
|
||||
adc1DMAProgram.startJob();
|
||||
}
|
||||
|
@ -35,10 +35,10 @@ uint8_t QSPIFlash::_buf[SFLASH_SECTOR_SIZE];
|
||||
uint32_t QSPIFlash::_addr = INVALID_ADDR;
|
||||
|
||||
void QSPIFlash::begin() {
|
||||
if (_flashBase != nullptr) return;
|
||||
if (_flashBase) return;
|
||||
|
||||
_flashBase = new Adafruit_SPIFlashBase(new Adafruit_FlashTransport_QSPI());
|
||||
_flashBase->begin(NULL);
|
||||
_flashBase->begin(nullptr);
|
||||
}
|
||||
|
||||
size_t QSPIFlash::size() {
|
||||
|
@ -99,7 +99,7 @@ void XPT2046::Init() {
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
SPIx.Instance = NULL;
|
||||
SPIx.Instance = nullptr;
|
||||
SET_INPUT(TOUCH_MISO_PIN);
|
||||
SET_OUTPUT(TOUCH_MOSI_PIN);
|
||||
SET_OUTPUT(TOUCH_SCK_PIN);
|
||||
|
@ -109,7 +109,7 @@
|
||||
// Private Variables
|
||||
// ------------------------
|
||||
|
||||
HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { NULL };
|
||||
HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { nullptr };
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
|
@ -124,7 +124,7 @@ void HAL_idletask();
|
||||
#endif
|
||||
|
||||
#ifndef digitalPinHasPWM
|
||||
#define digitalPinHasPWM(P) (PIN_MAP[P].timer_device != nullptr)
|
||||
#define digitalPinHasPWM(P) !!PIN_MAP[P].timer_device
|
||||
#define NO_COMPILE_TIME_PWM
|
||||
#endif
|
||||
|
||||
|
@ -656,7 +656,7 @@ static const spi_pins* dev_to_spi_pins(spi_dev *dev) {
|
||||
#if BOARD_NR_SPI >= 3
|
||||
case RCC_SPI3: return board_spi_pins + 2;
|
||||
#endif
|
||||
default: return NULL;
|
||||
default: return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@
|
||||
#define IS_INPUT(IO) (_GET_MODE(IO) == GPIO_INPUT_FLOATING || _GET_MODE(IO) == GPIO_INPUT_ANALOG || _GET_MODE(IO) == GPIO_INPUT_PU || _GET_MODE(IO) == GPIO_INPUT_PD)
|
||||
#define IS_OUTPUT(IO) (_GET_MODE(IO) == GPIO_OUTPUT_PP || _GET_MODE(IO) == GPIO_OUTPUT_OD)
|
||||
|
||||
#define PWM_PIN(IO) (PIN_MAP[IO].timer_device != nullptr)
|
||||
#define PWM_PIN(IO) !!PIN_MAP[IO].timer_device
|
||||
|
||||
// digitalRead/Write wrappers
|
||||
#define extDigitalRead(IO) digitalRead(IO)
|
||||
|
Reference in New Issue
Block a user