Nybbles & Bits

This commit is contained in:
Scott Lahteine
2021-02-04 19:37:59 -06:00
parent 604afd52d1
commit 49564e5310
5 changed files with 39 additions and 39 deletions

View File

@ -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>

View File

@ -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>

View File

@ -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);
}