Browse Source

Nybbles & Bits

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
49564e5310
  1. 24
      Marlin/src/libs/W25Qxx.cpp
  2. 24
      Marlin/src/module/planner.cpp
  3. 12
      Marlin/src/sd/usb_flashdrive/lib-uhs2/printhex.h
  4. 12
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printhex.h
  5. 6
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h

24
Marlin/src/libs/W25Qxx.cpp

@ -191,11 +191,11 @@ void W25QXXFlash::SPI_FLASH_SectorErase(uint32_t SectorAddr) {
W25QXX_CS_L; W25QXX_CS_L;
// Send Sector Erase instruction // Send Sector Erase instruction
spi_flash_Send(W25X_SectorErase); spi_flash_Send(W25X_SectorErase);
// Send SectorAddr high nibble address byte // Send SectorAddr high nybble address byte
spi_flash_Send((SectorAddr & 0xFF0000) >> 16); spi_flash_Send((SectorAddr & 0xFF0000) >> 16);
// Send SectorAddr medium nibble address byte // Send SectorAddr medium nybble address byte
spi_flash_Send((SectorAddr & 0xFF00) >> 8); spi_flash_Send((SectorAddr & 0xFF00) >> 8);
// Send SectorAddr low nibble address byte // Send SectorAddr low nybble address byte
spi_flash_Send(SectorAddr & 0xFF); spi_flash_Send(SectorAddr & 0xFF);
// Deselect the FLASH: Chip Select high // Deselect the FLASH: Chip Select high
@ -209,11 +209,11 @@ void W25QXXFlash::SPI_FLASH_BlockErase(uint32_t BlockAddr) {
W25QXX_CS_L; W25QXX_CS_L;
// Send Sector Erase instruction // Send Sector Erase instruction
spi_flash_Send(W25X_BlockErase); spi_flash_Send(W25X_BlockErase);
// Send SectorAddr high nibble address byte // Send SectorAddr high nybble address byte
spi_flash_Send((BlockAddr & 0xFF0000) >> 16); spi_flash_Send((BlockAddr & 0xFF0000) >> 16);
// Send SectorAddr medium nibble address byte // Send SectorAddr medium nybble address byte
spi_flash_Send((BlockAddr & 0xFF00) >> 8); spi_flash_Send((BlockAddr & 0xFF00) >> 8);
// Send SectorAddr low nibble address byte // Send SectorAddr low nybble address byte
spi_flash_Send(BlockAddr & 0xFF); spi_flash_Send(BlockAddr & 0xFF);
W25QXX_CS_H; W25QXX_CS_H;
@ -265,11 +265,11 @@ void W25QXXFlash::SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint
W25QXX_CS_L; W25QXX_CS_L;
// Send "Write to Memory " instruction // Send "Write to Memory " instruction
spi_flash_Send(W25X_PageProgram); spi_flash_Send(W25X_PageProgram);
// Send WriteAddr high nibble address byte to write to // Send WriteAddr high nybble address byte to write to
spi_flash_Send((WriteAddr & 0xFF0000) >> 16); spi_flash_Send((WriteAddr & 0xFF0000) >> 16);
// Send WriteAddr medium nibble address byte to write to // Send WriteAddr medium nybble address byte to write to
spi_flash_Send((WriteAddr & 0xFF00) >> 8); spi_flash_Send((WriteAddr & 0xFF00) >> 8);
// Send WriteAddr low nibble address byte to write to // Send WriteAddr low nybble address byte to write to
spi_flash_Send(WriteAddr & 0xFF); spi_flash_Send(WriteAddr & 0xFF);
NOMORE(NumByteToWrite, SPI_FLASH_PerWritePageSize); NOMORE(NumByteToWrite, SPI_FLASH_PerWritePageSize);
@ -371,11 +371,11 @@ void W25QXXFlash::SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint
// Send "Read from Memory " instruction // Send "Read from Memory " instruction
spi_flash_Send(W25X_ReadData); spi_flash_Send(W25X_ReadData);
// Send ReadAddr high nibble address byte to read from // Send ReadAddr high nybble address byte to read from
spi_flash_Send((ReadAddr & 0xFF0000) >> 16); spi_flash_Send((ReadAddr & 0xFF0000) >> 16);
// Send ReadAddr medium nibble address byte to read from // Send ReadAddr medium nybble address byte to read from
spi_flash_Send((ReadAddr & 0xFF00) >> 8); spi_flash_Send((ReadAddr & 0xFF00) >> 8);
// Send ReadAddr low nibble address byte to read from // Send ReadAddr low nybble address byte to read from
spi_flash_Send(ReadAddr & 0xFF); spi_flash_Send(ReadAddr & 0xFF);
if (NumByteToRead <= 32 || !flash_dma_mode) { if (NumByteToRead <= 32 || !flash_dma_mode) {

24
Marlin/src/module/planner.cpp

@ -418,11 +418,11 @@ void Planner::init() {
L("2") L("2")
A("cpi %16,0x10") // (nr & 0xF00000) == 0 ? A("cpi %16,0x10") // (nr & 0xF00000) == 0 ?
A("brcc 3f") // No, skip this A("brcc 3f") // No, skip this
A("swap %15") // Swap nibbles A("swap %15") // Swap nybbles
A("swap %16") // Swap nibbles. Low nibble is 0 A("swap %16") // Swap nybbles. Low nybble is 0
A("mov %14, %15") A("mov %14, %15")
A("andi %14,0x0F") // Isolate low nibble A("andi %14,0x0F") // Isolate low nybble
A("andi %15,0xF0") // Keep proper nibble in %15 A("andi %15,0xF0") // Keep proper nybble in %15
A("or %16, %14") // %16:%15 <<= 4 A("or %16, %14") // %16:%15 <<= 4
A("subi %3,-4") // idx += 4 A("subi %3,-4") // idx += 4
@ -473,10 +473,10 @@ void Planner::init() {
L("9") L("9")
A("sbrs %3,2") // shift by 4bits position? A("sbrs %3,2") // shift by 4bits position?
A("rjmp 16f") // No A("rjmp 16f") // No
A("swap %15") // Swap nibbles. lo nibble of %15 will always be 0 A("swap %15") // Swap nybbles. lo nybble of %15 will always be 0
A("swap %14") // Swap nibbles A("swap %14") // Swap nybbles
A("mov %12,%14") A("mov %12,%14")
A("andi %12,0x0F") // isolate low nibble A("andi %12,0x0F") // isolate low nybble
A("andi %14,0xF0") // and clear it A("andi %14,0xF0") // and clear it
A("or %15,%12") // %15:%16 <<= 4 A("or %15,%12") // %15:%16 <<= 4
L("16") L("16")
@ -504,11 +504,11 @@ void Planner::init() {
L("11") L("11")
A("sbrs %3,2") // shift by 4 bit position ? A("sbrs %3,2") // shift by 4 bit position ?
A("rjmp 12f") // No, skip it A("rjmp 12f") // No, skip it
A("swap %15") // Swap nibbles A("swap %15") // Swap nybbles
A("andi %14, 0xF0") // Lose the lowest nibble A("andi %14, 0xF0") // Lose the lowest nybble
A("swap %14") // Swap nibbles. Upper nibble is 0 A("swap %14") // Swap nybbles. Upper nybble is 0
A("or %14,%15") // Pass nibble from upper byte A("or %14,%15") // Pass nybble from upper byte
A("andi %15, 0x0F") // And get rid of that nibble A("andi %15, 0x0F") // And get rid of that nybble
L("12") L("12")
A("sbrs %3,3") // shift by 8 bit position ? A("sbrs %3,3") // shift by 8 bit position ?
A("rjmp 6f") // No, skip it A("rjmp 6f") // No, skip it

12
Marlin/src/sd/usb_flashdrive/lib-uhs2/printhex.h

@ -32,12 +32,12 @@ void E_Notifyc(char c, int lvl);
template <class T> template <class T>
void PrintHex(T val, int lvl) { void PrintHex(T val, int lvl) {
int num_nibbles = sizeof (T) * 2; int num_nybbles = sizeof (T) * 2;
do { do {
char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0F); char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F);
if (v > 57) v += 7; if (v > 57) v += 7;
E_Notifyc(v, lvl); E_Notifyc(v, lvl);
} while (--num_nibbles); } while (--num_nybbles);
} }
template <class T> template <class T>
@ -48,12 +48,12 @@ void PrintBin(T val, int lvl) {
template <class T> template <class T>
void SerialPrintHex(T val) { void SerialPrintHex(T val) {
int num_nibbles = sizeof (T) * 2; int num_nybbles = sizeof (T) * 2;
do { do {
char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0F); char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F);
if (v > 57) v += 7; if (v > 57) v += 7;
USB_HOST_SERIAL.print(v); USB_HOST_SERIAL.print(v);
} while (--num_nibbles); } while (--num_nybbles);
} }
template <class T> template <class T>

12
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printhex.h

@ -33,13 +33,13 @@ void E_Notifyc(char c, int lvl);
template <class T> template <class T>
void PrintHex(T val, int lvl) { void PrintHex(T val, int lvl) {
int num_nibbles = sizeof (T) * 2; int num_nybbles = sizeof (T) * 2;
do { do {
char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0F); char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F);
if(v > 57) v += 7; if(v > 57) v += 7;
E_Notifyc(v, lvl); E_Notifyc(v, lvl);
} while(--num_nibbles); } while(--num_nybbles);
} }
template <class T> template <class T>
@ -53,13 +53,13 @@ void PrintBin(T val, int lvl) {
template <class T> template <class T>
void SerialPrintHex(T val) { void SerialPrintHex(T val) {
int num_nibbles = sizeof (T) * 2; int num_nybbles = sizeof (T) * 2;
do { do {
char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0F); char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F);
if(v > 57) v += 7; if(v > 57) v += 7;
USB_HOST_SERIAL.print(v); USB_HOST_SERIAL.print(v);
} while(--num_nibbles); } while(--num_nybbles);
} }
template <class T> template <class T>

6
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h

@ -96,7 +96,7 @@ uint8_t* UHS_NI MAX3421E_HOST::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* dat
/* GPIO write */ /* GPIO write */
/*GPIO byte is split between 2 registers, so two writes are needed to write one byte */ /*GPIO byte is split between 2 registers, so two writes are needed to write one byte */
/* GPOUT bits are in the low nibble. 0-3 in IOPINS1, 4-7 in IOPINS2 */ /* GPOUT bits are in the low nybble. 0-3 in IOPINS1, 4-7 in IOPINS2 */
void UHS_NI MAX3421E_HOST::gpioWr(uint8_t data) { void UHS_NI MAX3421E_HOST::gpioWr(uint8_t data) {
regWr(rIOPINS1, data); regWr(rIOPINS1, data);
data >>= 4; data >>= 4;
@ -132,11 +132,11 @@ uint8_t* UHS_NI MAX3421E_HOST::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* dat
/* GPIO read. See gpioWr for explanation */ /* GPIO read. See gpioWr for explanation */
/* GPIN pins are in high nibbles of IOPINS1, IOPINS2 */ /* GPIN pins are in high nybbles of IOPINS1, IOPINS2 */
uint8_t UHS_NI MAX3421E_HOST::gpioRd() { uint8_t UHS_NI MAX3421E_HOST::gpioRd() {
uint8_t gpin = 0; uint8_t gpin = 0;
gpin = regRd(rIOPINS2); //pins 4-7 gpin = regRd(rIOPINS2); //pins 4-7
gpin &= 0xF0; //clean lower nibble gpin &= 0xF0; //clean lower nybble
gpin |= (regRd(rIOPINS1) >> 4); //shift low bits and OR with upper from previous operation. gpin |= (regRd(rIOPINS1) >> 4); //shift low bits and OR with upper from previous operation.
return ( gpin); return ( gpin);
} }

Loading…
Cancel
Save