Nybbles & Bits
This commit is contained in:
parent
604afd52d1
commit
49564e5310
@ -191,11 +191,11 @@ void W25QXXFlash::SPI_FLASH_SectorErase(uint32_t SectorAddr) {
|
||||
W25QXX_CS_L;
|
||||
// Send Sector Erase instruction
|
||||
spi_flash_Send(W25X_SectorErase);
|
||||
// Send SectorAddr high nibble address byte
|
||||
// Send SectorAddr high nybble address byte
|
||||
spi_flash_Send((SectorAddr & 0xFF0000) >> 16);
|
||||
// Send SectorAddr medium nibble address byte
|
||||
// Send SectorAddr medium nybble address byte
|
||||
spi_flash_Send((SectorAddr & 0xFF00) >> 8);
|
||||
// Send SectorAddr low nibble address byte
|
||||
// Send SectorAddr low nybble address byte
|
||||
spi_flash_Send(SectorAddr & 0xFF);
|
||||
// Deselect the FLASH: Chip Select high
|
||||
|
||||
@ -209,11 +209,11 @@ void W25QXXFlash::SPI_FLASH_BlockErase(uint32_t BlockAddr) {
|
||||
W25QXX_CS_L;
|
||||
// Send Sector Erase instruction
|
||||
spi_flash_Send(W25X_BlockErase);
|
||||
// Send SectorAddr high nibble address byte
|
||||
// Send SectorAddr high nybble address byte
|
||||
spi_flash_Send((BlockAddr & 0xFF0000) >> 16);
|
||||
// Send SectorAddr medium nibble address byte
|
||||
// Send SectorAddr medium nybble address byte
|
||||
spi_flash_Send((BlockAddr & 0xFF00) >> 8);
|
||||
// Send SectorAddr low nibble address byte
|
||||
// Send SectorAddr low nybble address byte
|
||||
spi_flash_Send(BlockAddr & 0xFF);
|
||||
|
||||
W25QXX_CS_H;
|
||||
@ -265,11 +265,11 @@ void W25QXXFlash::SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint
|
||||
W25QXX_CS_L;
|
||||
// Send "Write to Memory " instruction
|
||||
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);
|
||||
// Send WriteAddr medium nibble address byte to write to
|
||||
// Send WriteAddr medium nybble address byte to write to
|
||||
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);
|
||||
|
||||
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
|
||||
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);
|
||||
// Send ReadAddr medium nibble address byte to read from
|
||||
// Send ReadAddr medium nybble address byte to read from
|
||||
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);
|
||||
|
||||
if (NumByteToRead <= 32 || !flash_dma_mode) {
|
||||
|
@ -418,11 +418,11 @@ void Planner::init() {
|
||||
L("2")
|
||||
A("cpi %16,0x10") // (nr & 0xF00000) == 0 ?
|
||||
A("brcc 3f") // No, skip this
|
||||
A("swap %15") // Swap nibbles
|
||||
A("swap %16") // Swap nibbles. Low nibble is 0
|
||||
A("swap %15") // Swap nybbles
|
||||
A("swap %16") // Swap nybbles. Low nybble is 0
|
||||
A("mov %14, %15")
|
||||
A("andi %14,0x0F") // Isolate low nibble
|
||||
A("andi %15,0xF0") // Keep proper nibble in %15
|
||||
A("andi %14,0x0F") // Isolate low nybble
|
||||
A("andi %15,0xF0") // Keep proper nybble in %15
|
||||
A("or %16, %14") // %16:%15 <<= 4
|
||||
A("subi %3,-4") // idx += 4
|
||||
|
||||
@ -473,10 +473,10 @@ void Planner::init() {
|
||||
L("9")
|
||||
A("sbrs %3,2") // shift by 4bits position?
|
||||
A("rjmp 16f") // No
|
||||
A("swap %15") // Swap nibbles. lo nibble of %15 will always be 0
|
||||
A("swap %14") // Swap nibbles
|
||||
A("swap %15") // Swap nybbles. lo nybble of %15 will always be 0
|
||||
A("swap %14") // Swap nybbles
|
||||
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("or %15,%12") // %15:%16 <<= 4
|
||||
L("16")
|
||||
@ -504,11 +504,11 @@ void Planner::init() {
|
||||
L("11")
|
||||
A("sbrs %3,2") // shift by 4 bit position ?
|
||||
A("rjmp 12f") // No, skip it
|
||||
A("swap %15") // Swap nibbles
|
||||
A("andi %14, 0xF0") // Lose the lowest nibble
|
||||
A("swap %14") // Swap nibbles. Upper nibble is 0
|
||||
A("or %14,%15") // Pass nibble from upper byte
|
||||
A("andi %15, 0x0F") // And get rid of that nibble
|
||||
A("swap %15") // Swap nybbles
|
||||
A("andi %14, 0xF0") // Lose the lowest nybble
|
||||
A("swap %14") // Swap nybbles. Upper nybble is 0
|
||||
A("or %14,%15") // Pass nybble from upper byte
|
||||
A("andi %15, 0x0F") // And get rid of that nybble
|
||||
L("12")
|
||||
A("sbrs %3,3") // shift by 8 bit position ?
|
||||
A("rjmp 6f") // No, skip it
|
||||
|
@ -32,12 +32,12 @@ void E_Notifyc(char c, int lvl);
|
||||
|
||||
template <class T>
|
||||
void PrintHex(T val, int lvl) {
|
||||
int num_nibbles = sizeof (T) * 2;
|
||||
int num_nybbles = sizeof (T) * 2;
|
||||
do {
|
||||
char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0F);
|
||||
char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F);
|
||||
if (v > 57) v += 7;
|
||||
E_Notifyc(v, lvl);
|
||||
} while (--num_nibbles);
|
||||
} while (--num_nybbles);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@ -48,12 +48,12 @@ void PrintBin(T val, int lvl) {
|
||||
|
||||
template <class T>
|
||||
void SerialPrintHex(T val) {
|
||||
int num_nibbles = sizeof (T) * 2;
|
||||
int num_nybbles = sizeof (T) * 2;
|
||||
do {
|
||||
char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0F);
|
||||
char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F);
|
||||
if (v > 57) v += 7;
|
||||
USB_HOST_SERIAL.print(v);
|
||||
} while (--num_nibbles);
|
||||
} while (--num_nybbles);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -33,13 +33,13 @@ void E_Notifyc(char c, int lvl);
|
||||
|
||||
template <class T>
|
||||
void PrintHex(T val, int lvl) {
|
||||
int num_nibbles = sizeof (T) * 2;
|
||||
int num_nybbles = sizeof (T) * 2;
|
||||
|
||||
do {
|
||||
char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0F);
|
||||
char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F);
|
||||
if(v > 57) v += 7;
|
||||
E_Notifyc(v, lvl);
|
||||
} while(--num_nibbles);
|
||||
} while(--num_nybbles);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@ -53,13 +53,13 @@ void PrintBin(T val, int lvl) {
|
||||
|
||||
template <class T>
|
||||
void SerialPrintHex(T val) {
|
||||
int num_nibbles = sizeof (T) * 2;
|
||||
int num_nybbles = sizeof (T) * 2;
|
||||
|
||||
do {
|
||||
char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0F);
|
||||
char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F);
|
||||
if(v > 57) v += 7;
|
||||
USB_HOST_SERIAL.print(v);
|
||||
} while(--num_nibbles);
|
||||
} while(--num_nybbles);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -96,7 +96,7 @@ uint8_t* UHS_NI MAX3421E_HOST::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* dat
|
||||
/* GPIO write */
|
||||
/*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) {
|
||||
regWr(rIOPINS1, data);
|
||||
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 */
|
||||
|
||||
/* 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 gpin = 0;
|
||||
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.
|
||||
return ( gpin);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user