diff --git a/examples/4digitdisplay.cxx b/examples/4digitdisplay.cxx index f12fe87e..5aeace6a 100644 --- a/examples/4digitdisplay.cxx +++ b/examples/4digitdisplay.cxx @@ -29,14 +29,14 @@ int main(int argc, char **argv) { - uint8_t data[] = { 0xaa, 0xff, 0xff, 0xff }; + uint8_t data[] = { 0xaa, 0xff, 0xff, 0xff }; upm::TM1637 *display = new upm::TM1637(8, 9); // di - 8, dcki - 9 - display->write ("1981"); - - std::cout << "exiting application" << std::endl; + display->write ("1981"); + + std::cout << "exiting application" << std::endl; - delete display; + delete display; return 0; } diff --git a/examples/buzzer-sound.cxx b/examples/buzzer-sound.cxx index e189e111..3941c3e8 100644 --- a/examples/buzzer-sound.cxx +++ b/examples/buzzer-sound.cxx @@ -33,7 +33,7 @@ int running = 0; void sig_handler(int signo) { - printf("got signal\n"); + printf("got signal\n"); if (signo == SIGINT) { printf("exiting application\n"); running = 1; @@ -42,25 +42,25 @@ sig_handler(int signo) int main(int argc, char **argv) { - int chord[] = { DO, RE, MI, FA, SOL, LA, SI, DO, SI }; - // create Buzzer instance + int chord[] = { DO, RE, MI, FA, SOL, LA, SI, DO, SI }; + // create Buzzer instance upm::Buzzer* sound = new upm::Buzzer(5); - // print sensor name + // print sensor name std::cout << sound->name() << std::endl; - // play sound (DO, RE, ME, etc...) + // play sound (DO, RE, ME, etc...) - signal(SIGINT, sig_handler); + signal(SIGINT, sig_handler); - while (!running) { - for (int chord_ind = 0; chord_ind < 9; chord_ind++) { - std::cout << sound->playSound(chord[chord_ind]) << std::endl; - usleep(1000); - } - } + while (!running) { + for (int chord_ind = 0; chord_ind < 9; chord_ind++) { + std::cout << sound->playSound(chord[chord_ind]) << std::endl; + usleep(1000); + } + } - std::cout << "exiting application" << std::endl; + std::cout << "exiting application" << std::endl; - delete sound; + delete sound; return 0; } diff --git a/examples/led-bar.cxx b/examples/led-bar.cxx index 02ed4435..790a4250 100644 --- a/examples/led-bar.cxx +++ b/examples/led-bar.cxx @@ -32,7 +32,7 @@ int running = 0; void sig_handler(int signo) { - printf("got signal\n"); + printf("got signal\n"); if (signo == SIGINT) { printf("exiting application\n"); running = 1; @@ -43,19 +43,19 @@ int main(int argc, char **argv) { upm::MY9221 *bar = new upm::MY9221(8, 9); - - signal(SIGINT, sig_handler); + + signal(SIGINT, sig_handler); - while (!running) { - for (int idx = 1; idx < 11; idx++) { - bar->setBarLevel (idx); - usleep(1000); - } - } + while (!running) { + for (int idx = 1; idx < 11; idx++) { + bar->setBarLevel (idx); + usleep(1000); + } + } - std::cout << "exiting application" << std::endl; + std::cout << "exiting application" << std::endl; - delete bar; + delete bar; return 0; } diff --git a/examples/nrf_receiver.cxx b/examples/nrf_receiver.cxx index 77ce5710..294b1751 100644 --- a/examples/nrf_receiver.cxx +++ b/examples/nrf_receiver.cxx @@ -34,7 +34,7 @@ upm::NRF24l01 *comm = NULL; void sig_handler(int signo) { - printf("got signal\n"); + printf("got signal\n"); if (signo == SIGINT) { printf("exiting application\n"); running = 1; @@ -42,28 +42,28 @@ sig_handler(int signo) } void nrf_handler () { - std::cout << "devi1 :: " << *((uint32_t *)&(comm->m_rxBuffer[0])) << std::endl; + std::cout << "devi1 :: " << *((uint32_t *)&(comm->m_rxBuffer[0])) << std::endl; } int main(int argc, char **argv) { comm = new upm::NRF24l01(7); - comm->nrfSetRXaddr ((uint8_t *) "devi1"); - comm->nrfSetTXaddr ((uint8_t *) "devi2"); - comm->nrfSetPayload (MAX_BUFFER); - comm->nrfConfigModule (); - comm->dataRecievedHandler = nrf_handler; - - signal(SIGINT, sig_handler); + comm->nrfSetRXaddr ((uint8_t *) "devi1"); + comm->nrfSetTXaddr ((uint8_t *) "devi2"); + comm->nrfSetPayload (MAX_BUFFER); + comm->nrfConfigModule (); + comm->dataRecievedHandler = nrf_handler; + + signal(SIGINT, sig_handler); - while (!running) { - comm->nrfListenForChannel (); - } + while (!running) { + comm->nrfListenForChannel (); + } - std::cout << "exiting application" << std::endl; + std::cout << "exiting application" << std::endl; - delete comm; + delete comm; return 0; } diff --git a/examples/nrf_transmitter.cxx b/examples/nrf_transmitter.cxx index 0679f383..52c46434 100644 --- a/examples/nrf_transmitter.cxx +++ b/examples/nrf_transmitter.cxx @@ -34,7 +34,7 @@ upm::NRF24l01 *comm = NULL; void sig_handler(int signo) { - printf("got signal\n"); + printf("got signal\n"); if (signo == SIGINT) { printf("exiting application\n"); running = 1; @@ -47,27 +47,27 @@ void nrf_handler () { int main(int argc, char **argv) { - uint32_t dummyData = 0; + uint32_t dummyData = 0; comm = new upm::NRF24l01(7); - comm->nrfSetRXaddr ((uint8_t *) "devi2"); - comm->nrfSetTXaddr ((uint8_t *) "devi1"); - comm->nrfSetPayload (MAX_BUFFER); - comm->nrfConfigModule (); - comm->dataRecievedHandler = nrf_handler; - - signal(SIGINT, sig_handler); + comm->nrfSetRXaddr ((uint8_t *) "devi2"); + comm->nrfSetTXaddr ((uint8_t *) "devi1"); + comm->nrfSetPayload (MAX_BUFFER); + comm->nrfConfigModule (); + comm->dataRecievedHandler = nrf_handler; + + signal(SIGINT, sig_handler); - while (!running) { - memcpy (comm->m_txBuffer, &dummyData, sizeof (dummyData)); - comm->nrfSend (); - std::cout << "devi2 :: sending data ...." << dummyData << std::endl; - usleep (3000000); - dummyData += 3000; - } + while (!running) { + memcpy (comm->m_txBuffer, &dummyData, sizeof (dummyData)); + comm->nrfSend (); + std::cout << "devi2 :: sending data ...." << dummyData << std::endl; + usleep (3000000); + dummyData += 3000; + } - std::cout << "exiting application" << std::endl; + std::cout << "exiting application" << std::endl; - delete comm; + delete comm; return 0; } diff --git a/examples/rgb-lcd.cxx b/examples/rgb-lcd.cxx index 0954de76..f0d55d1a 100644 --- a/examples/rgb-lcd.cxx +++ b/examples/rgb-lcd.cxx @@ -27,9 +27,9 @@ int main(int argc, char **argv) { - // 0x62 RGB_ADDRESS, 0x3E LCD_ADDRESS + // 0x62 RGB_ADDRESS, 0x3E LCD_ADDRESS upm::Jhd1313m1 *lcd = new upm::Jhd1313m1(0, 0x3E, 0x62); - lcd->setCursor(0,0); + lcd->setCursor(0,0); lcd->write("Hello World"); lcd->setCursor(1,2); lcd->write("Hello World"); diff --git a/src/4digitdisplay/tm1637.cxx b/src/4digitdisplay/tm1637.cxx index e18068eb..e48baa0b 100644 --- a/src/4digitdisplay/tm1637.cxx +++ b/src/4digitdisplay/tm1637.cxx @@ -31,65 +31,65 @@ using namespace upm; const uint8_t digitToSegment[] = { - // XGFEDCBA - 0b00111111, // 0 - 0b00000110, // 1 - 0b01011011, // 2 - 0b01001111, // 3 - 0b01100110, // 4 - 0b01101101, // 5 - 0b01111101, // 6 - 0b00000111, // 7 - 0b01111111, // 8 - 0b01101111, // 9 - 0b01110111, // A - 0b01111100, // B - 0b00111001, // C - 0b01000111, // D - 0b01111001, // E - 0b01110001 // F + // XGFEDCBA + 0b00111111, // 0 + 0b00000110, // 1 + 0b01011011, // 2 + 0b01001111, // 3 + 0b01100110, // 4 + 0b01101101, // 5 + 0b01111101, // 6 + 0b00000111, // 7 + 0b01111111, // 8 + 0b01101111, // 9 + 0b01110111, // A + 0b01111100, // B + 0b00111001, // C + 0b01000111, // D + 0b01111001, // E + 0b01110001 // F }; TM1637::TM1637 (uint8_t di, uint8_t dcki) { - maa_result_t error = MAA_SUCCESS; - maa_init(); + maa_result_t error = MAA_SUCCESS; + maa_init(); - // init clock context - m_clkPinCtx = maa_gpio_init(dcki); - if (m_clkPinCtx == NULL) { + // init clock context + m_clkPinCtx = maa_gpio_init(dcki); + if (m_clkPinCtx == NULL) { fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", dcki); - exit(1); - } - // init data context - m_dataPinCtx = maa_gpio_init(di); - if (m_dataPinCtx == NULL) { + exit(1); + } + // init data context + m_dataPinCtx = maa_gpio_init(di); + if (m_dataPinCtx == NULL) { fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", di); - exit(1); - } - - // set direction (out) - error = maa_gpio_dir(m_clkPinCtx, MAA_GPIO_IN); + exit(1); + } + + // set direction (out) + error = maa_gpio_dir(m_clkPinCtx, MAA_GPIO_IN); if (error != MAA_SUCCESS) { maa_result_print(error); } - // set direction (out) - error = maa_gpio_dir(m_dataPinCtx, MAA_GPIO_IN); + // set direction (out) + error = maa_gpio_dir(m_dataPinCtx, MAA_GPIO_IN); if (error != MAA_SUCCESS) { maa_result_print(error); } - error = maa_gpio_write (m_dataPinCtx, LOW); - error = maa_gpio_write (m_clkPinCtx, LOW); + error = maa_gpio_write (m_dataPinCtx, LOW); + error = maa_gpio_write (m_clkPinCtx, LOW); } TM1637::~TM1637() { - maa_result_t error = MAA_SUCCESS; - error = maa_gpio_close (m_dataPinCtx); + maa_result_t error = MAA_SUCCESS; + error = maa_gpio_close (m_dataPinCtx); if (error != MAA_SUCCESS) { maa_result_print(error); } - error = maa_gpio_close (m_clkPinCtx); + error = maa_gpio_close (m_clkPinCtx); if (error != MAA_SUCCESS) { maa_result_print(error); } @@ -97,45 +97,45 @@ TM1637::~TM1637() { maa_result_t TM1637::setBrightness (uint8_t level) { - m_brightness = level; + m_brightness = level; } maa_result_t TM1637::setSegments (const uint8_t segments[], uint8_t length, uint8_t pos) { - start(); - writeByte(TM1637_I2C_COMM1); - stop(); + start(); + writeByte(TM1637_I2C_COMM1); + stop(); - start(); - writeByte(TM1637_I2C_COMM2 + (pos & 0x03)); - for (uint8_t idx = 0; idx < length; idx++) { - writeByte(segments[idx]); - } - stop(); + start(); + writeByte(TM1637_I2C_COMM2 + (pos & 0x03)); + for (uint8_t idx = 0; idx < length; idx++) { + writeByte(segments[idx]); + } + stop(); - start(); - writeByte(TM1637_I2C_COMM3 + (m_brightness & 0x0f)); - stop(); + start(); + writeByte(TM1637_I2C_COMM3 + (m_brightness & 0x0f)); + stop(); } maa_result_t TM1637::write (std::string msg) { - char leter = '\0'; - uint8_t data[] = { 0x0, 0x0, 0x0, 0x0 }; - for (uint8_t idx = 0; idx < msg.length(); idx++) { - leter = msg[idx]; - if (idx < 4) { - data[idx] = digitToSegment[strtol(&leter, NULL, 16)]; - } - } - setBrightness (0x0f); - setSegments(data); + char leter = '\0'; + uint8_t data[] = { 0x0, 0x0, 0x0, 0x0 }; + for (uint8_t idx = 0; idx < msg.length(); idx++) { + leter = msg[idx]; + if (idx < 4) { + data[idx] = digitToSegment[strtol(&leter, NULL, 16)]; + } + } + setBrightness (0x0f); + setSegments(data); } maa_result_t TM1637::pinMode (maa_gpio_context ctx, gpio_dir_t mode) { - maa_result_t error = MAA_SUCCESS; - error = maa_gpio_dir(ctx, mode); + maa_result_t error = MAA_SUCCESS; + error = maa_gpio_dir(ctx, mode); if (error != MAA_SUCCESS) { maa_result_print(error); } @@ -143,49 +143,49 @@ TM1637::pinMode (maa_gpio_context ctx, gpio_dir_t mode) { maa_result_t TM1637::start() { - pinMode (m_dataPinCtx, MAA_GPIO_OUT); - usleep(PULSE_LENGTH); + pinMode (m_dataPinCtx, MAA_GPIO_OUT); + usleep(PULSE_LENGTH); } maa_result_t TM1637::stop() { - pinMode (m_dataPinCtx, MAA_GPIO_OUT); - usleep(PULSE_LENGTH); - pinMode (m_clkPinCtx, MAA_GPIO_IN); - usleep(PULSE_LENGTH); - pinMode (m_dataPinCtx, MAA_GPIO_IN); - usleep(PULSE_LENGTH); + pinMode (m_dataPinCtx, MAA_GPIO_OUT); + usleep(PULSE_LENGTH); + pinMode (m_clkPinCtx, MAA_GPIO_IN); + usleep(PULSE_LENGTH); + pinMode (m_dataPinCtx, MAA_GPIO_IN); + usleep(PULSE_LENGTH); } maa_result_t TM1637::writeByte(uint8_t value) { - for (uint8_t idx = 0; idx < 8; idx++) { - pinMode(m_clkPinCtx, MAA_GPIO_OUT); - usleep(PULSE_LENGTH); - if (value & 0x01) { - pinMode(m_dataPinCtx, MAA_GPIO_IN); - } else { - pinMode(m_dataPinCtx, MAA_GPIO_OUT); - } - usleep(PULSE_LENGTH); + for (uint8_t idx = 0; idx < 8; idx++) { + pinMode(m_clkPinCtx, MAA_GPIO_OUT); + usleep(PULSE_LENGTH); + if (value & 0x01) { + pinMode(m_dataPinCtx, MAA_GPIO_IN); + } else { + pinMode(m_dataPinCtx, MAA_GPIO_OUT); + } + usleep(PULSE_LENGTH); - pinMode(m_clkPinCtx, MAA_GPIO_IN); - usleep(PULSE_LENGTH); - value = value >> 1; - } + pinMode(m_clkPinCtx, MAA_GPIO_IN); + usleep(PULSE_LENGTH); + value = value >> 1; + } - pinMode(m_clkPinCtx, MAA_GPIO_OUT); - pinMode(m_dataPinCtx, MAA_GPIO_IN); - usleep(PULSE_LENGTH); + pinMode(m_clkPinCtx, MAA_GPIO_OUT); + pinMode(m_dataPinCtx, MAA_GPIO_IN); + usleep(PULSE_LENGTH); - pinMode(m_clkPinCtx, MAA_GPIO_IN); - usleep(PULSE_LENGTH); + pinMode(m_clkPinCtx, MAA_GPIO_IN); + usleep(PULSE_LENGTH); - uint8_t ack = maa_gpio_read (m_dataPinCtx); - if (ack == 0) { - pinMode(m_dataPinCtx, MAA_GPIO_OUT); - } usleep(PULSE_LENGTH); + uint8_t ack = maa_gpio_read (m_dataPinCtx); + if (ack == 0) { + pinMode(m_dataPinCtx, MAA_GPIO_OUT); + } usleep(PULSE_LENGTH); - pinMode(m_clkPinCtx, MAA_GPIO_OUT); - usleep(50); + pinMode(m_clkPinCtx, MAA_GPIO_OUT); + usleep(50); } diff --git a/src/4digitdisplay/tm1637.h b/src/4digitdisplay/tm1637.h index 79c0ef36..1f6a937c 100644 --- a/src/4digitdisplay/tm1637.h +++ b/src/4digitdisplay/tm1637.h @@ -36,47 +36,47 @@ // --- // D -#define SEG_A 0b00000001 -#define SEG_B 0b00000010 -#define SEG_C 0b00000100 -#define SEG_D 0b00001000 -#define SEG_E 0b00010000 -#define SEG_F 0b00100000 -#define SEG_G 0b01000000 +#define SEG_A 0b00000001 +#define SEG_B 0b00000010 +#define SEG_C 0b00000100 +#define SEG_D 0b00001000 +#define SEG_E 0b00010000 +#define SEG_F 0b00100000 +#define SEG_G 0b01000000 #define TM1637_I2C_COMM1 0x40 #define TM1637_I2C_COMM2 0xC0 #define TM1637_I2C_COMM3 0x80 -#define PULSE_LENGTH 50 +#define PULSE_LENGTH 50 -#define HIGH 1 -#define LOW 0 +#define HIGH 1 +#define LOW 0 namespace upm { class TM1637 { public: - TM1637 (uint8_t di, uint8_t dcki); - ~TM1637 (); - maa_result_t setBrightness (uint8_t level); - maa_result_t setSegments (const uint8_t segments[], uint8_t length = 4, uint8_t pos = 0); - maa_result_t write (std::string msg); - - std::string name() + TM1637 (uint8_t di, uint8_t dcki); + ~TM1637 (); + maa_result_t setBrightness (uint8_t level); + maa_result_t setSegments (const uint8_t segments[], uint8_t length = 4, uint8_t pos = 0); + maa_result_t write (std::string msg); + + std::string name() { return m_name; } - private: - maa_result_t start(); - maa_result_t stop(); - maa_result_t writeByte (uint8_t value); - maa_result_t pinMode (maa_gpio_context ctx, gpio_dir_t mode); + private: + maa_result_t start(); + maa_result_t stop(); + maa_result_t writeByte (uint8_t value); + maa_result_t pinMode (maa_gpio_context ctx, gpio_dir_t mode); - std::string m_name; - maa_gpio_context m_clkPinCtx; - maa_gpio_context m_dataPinCtx; - uint8_t m_brightness; + std::string m_name; + maa_gpio_context m_clkPinCtx; + maa_gpio_context m_dataPinCtx; + uint8_t m_brightness; }; } diff --git a/src/buzzer/buzzer.cxx b/src/buzzer/buzzer.cxx index 8800f46a..674ff224 100644 --- a/src/buzzer/buzzer.cxx +++ b/src/buzzer/buzzer.cxx @@ -30,22 +30,22 @@ using namespace upm; Buzzer::Buzzer (int pinNumber) { - m_pwm_context = maa_pwm_init (pinNumber); - m_name = "Buzzer"; + m_pwm_context = maa_pwm_init (pinNumber); + m_name = "Buzzer"; } int Buzzer::playSound (int note) { - maa_pwm_enable (m_pwm_context, 1); - maa_pwm_period_us (m_pwm_context, note); - maa_pwm_write (m_pwm_context, 50.0); - usleep (10000); - maa_pwm_enable (m_pwm_context, 0); + maa_pwm_enable (m_pwm_context, 1); + maa_pwm_period_us (m_pwm_context, note); + maa_pwm_write (m_pwm_context, 50.0); + usleep (10000); + maa_pwm_enable (m_pwm_context, 0); - return 0; + return 0; } Buzzer::~Buzzer() { - maa_pwm_close(m_pwm_context); - std::cout << "executed maa_pwm_close" << std::endl; + maa_pwm_close(m_pwm_context); + std::cout << "executed maa_pwm_close" << std::endl; } diff --git a/src/buzzer/buzzer.h b/src/buzzer/buzzer.h index c3ce06c6..0a3ac1c2 100644 --- a/src/buzzer/buzzer.h +++ b/src/buzzer/buzzer.h @@ -38,16 +38,16 @@ namespace upm { class Buzzer { public: - Buzzer (int pinNumber); - ~Buzzer (); - int playSound (int note); + Buzzer (int pinNumber); + ~Buzzer (); + int playSound (int note); std::string name() { return m_name; } protected: std::string m_name; - private: - maa_pwm_context m_pwm_context; + private: + maa_pwm_context m_pwm_context; }; } diff --git a/src/lcd/iiclcd.cxx b/src/lcd/iiclcd.cxx index 8eb2c546..aec56f12 100644 --- a/src/lcd/iiclcd.cxx +++ b/src/lcd/iiclcd.cxx @@ -30,24 +30,24 @@ using namespace upm; IICLcd::IICLcd (int bus, int lcdAddress) { - m_lcd_control_address = lcdAddress; + m_lcd_control_address = lcdAddress; m_bus = bus; m_i2c_lcd_control = maa_i2c_init(m_bus); maa_result_t ret = maa_i2c_address(m_i2c_lcd_control, m_lcd_control_address); - if (ret != MAA_SUCCESS) { + if (ret != MAA_SUCCESS) { fprintf(stderr, "Messed up i2c bus\n"); } } maa_result_t IICLcd::write (int row, int column, std::string msg) { - setCursor (row, column); - write (msg); + setCursor (row, column); + write (msg); } maa_result_t IICLcd::close() { - return maa_i2c_stop(m_i2c_lcd_control); + return maa_i2c_stop(m_i2c_lcd_control); } diff --git a/src/lcd/iiclcd.h b/src/lcd/iiclcd.h index c56f92ae..c36a9e17 100644 --- a/src/lcd/iiclcd.h +++ b/src/lcd/iiclcd.h @@ -68,23 +68,23 @@ namespace upm { #define LCD_RS 0x01 // Register select bit class IICLcd { - public: - IICLcd (int bus, int lcdAddress); - virtual maa_result_t write (std::string msg) = 0; - maa_result_t write (int x, int y, std::string msg); - virtual maa_result_t setCursor (int row, int column) = 0; - virtual maa_result_t clear () = 0; - virtual maa_result_t home () = 0; - maa_result_t close(); - std::string name() + public: + IICLcd (int bus, int lcdAddress); + virtual maa_result_t write (std::string msg) = 0; + maa_result_t write (int x, int y, std::string msg); + virtual maa_result_t setCursor (int row, int column) = 0; + virtual maa_result_t clear () = 0; + virtual maa_result_t home () = 0; + maa_result_t close(); + std::string name() { return m_name; } - protected: - std::string m_name; - int m_lcd_control_address; - int m_bus; - maa_i2c_context m_i2c_lcd_control; + protected: + std::string m_name; + int m_lcd_control_address; + int m_bus; + maa_i2c_context m_i2c_lcd_control; }; } diff --git a/src/lcd/jhd1313m1.cxx b/src/lcd/jhd1313m1.cxx index 79dad8b9..eb114e97 100644 --- a/src/lcd/jhd1313m1.cxx +++ b/src/lcd/jhd1313m1.cxx @@ -30,44 +30,44 @@ using namespace upm; Jhd1313m1::Jhd1313m1 (int bus, int lcdAddress, int rgbAddress) : IICLcd(bus, lcdAddress) { - maa_result_t error = MAA_SUCCESS; + maa_result_t error = MAA_SUCCESS; - m_rgb_address = rgbAddress; - m_i2c_lcd_rgb = maa_i2c_init(m_bus); + m_rgb_address = rgbAddress; + m_i2c_lcd_rgb = maa_i2c_init(m_bus); - maa_result_t ret = maa_i2c_address(m_i2c_lcd_rgb, m_rgb_address); - if (ret != MAA_SUCCESS) { + maa_result_t ret = maa_i2c_address(m_i2c_lcd_rgb, m_rgb_address); + if (ret != MAA_SUCCESS) { fprintf(stderr, "Messed up i2c bus\n"); } - usleep(50000); + usleep(50000); + cmd (m_i2c_lcd_control, LCD_FUNCTIONSET | LCD_2LINE); + usleep(4500); + cmd (m_i2c_lcd_control, LCD_FUNCTIONSET | LCD_2LINE); + usleep(4500); + cmd (m_i2c_lcd_control, LCD_FUNCTIONSET | LCD_2LINE); + usleep(4500); cmd (m_i2c_lcd_control, LCD_FUNCTIONSET | LCD_2LINE); - usleep(4500); - cmd (m_i2c_lcd_control, LCD_FUNCTIONSET | LCD_2LINE); - usleep(4500); - cmd (m_i2c_lcd_control, LCD_FUNCTIONSET | LCD_2LINE); - usleep(4500); - cmd (m_i2c_lcd_control, LCD_FUNCTIONSET | LCD_2LINE); - cmd (m_i2c_lcd_control, LCD_DISPLAYCONTROL | LCD_DISPLAYON); - clear (); - usleep(4500); - - cmd (m_i2c_lcd_control, LCD_ENTRYMODESET | - LCD_ENTRYLEFT | - LCD_ENTRYSHIFTDECREMENT); + cmd (m_i2c_lcd_control, LCD_DISPLAYCONTROL | LCD_DISPLAYON); + clear (); + usleep(4500); + + cmd (m_i2c_lcd_control, LCD_ENTRYMODESET | + LCD_ENTRYLEFT | + LCD_ENTRYSHIFTDECREMENT); - setReg (m_i2c_lcd_rgb, m_rgb_address, 0, 0); - setReg (m_i2c_lcd_rgb, m_rgb_address, 1, 0); - setReg (m_i2c_lcd_rgb, m_rgb_address, 0x08, 0xAA); + setReg (m_i2c_lcd_rgb, m_rgb_address, 0, 0); + setReg (m_i2c_lcd_rgb, m_rgb_address, 1, 0); + setReg (m_i2c_lcd_rgb, m_rgb_address, 0x08, 0xAA); - setReg (m_i2c_lcd_rgb, m_rgb_address, 0x04, 255); + setReg (m_i2c_lcd_rgb, m_rgb_address, 0x04, 255); setReg (m_i2c_lcd_rgb, m_rgb_address, 0x03, 255); setReg (m_i2c_lcd_rgb, m_rgb_address, 0x02, 255); } Jhd1313m1::~Jhd1313m1() { - + } /* @@ -77,39 +77,39 @@ Jhd1313m1::~Jhd1313m1() { */ maa_result_t Jhd1313m1::write (std::string msg) { - maa_result_t error = MAA_SUCCESS; - uint8_t data[2] = {0x40, 0}; - for (std::string::size_type i = 0; i < msg.size(); ++i) { - data[1] = msg[i]; - error = maa_i2c_address (m_i2c_lcd_control, m_lcd_control_address); - error = maa_i2c_write (m_i2c_lcd_control, data, 2); + maa_result_t error = MAA_SUCCESS; + uint8_t data[2] = {0x40, 0}; + for (std::string::size_type i = 0; i < msg.size(); ++i) { + data[1] = msg[i]; + error = maa_i2c_address (m_i2c_lcd_control, m_lcd_control_address); + error = maa_i2c_write (m_i2c_lcd_control, data, 2); } - return error; + return error; } maa_result_t Jhd1313m1::setCursor (int row, int column) { - maa_result_t error = MAA_SUCCESS; + maa_result_t error = MAA_SUCCESS; - int row_addr[] = { 0x80, 0xc0, 0x14, 0x54}; - uint8_t offset = ((column % 16) + row_addr[row]); + int row_addr[] = { 0x80, 0xc0, 0x14, 0x54}; + uint8_t offset = ((column % 16) + row_addr[row]); - uint8_t data[2] = { 0x80, offset }; - error = maa_i2c_address (m_i2c_lcd_control, m_lcd_control_address); - error = maa_i2c_write (m_i2c_lcd_control, data, 2); + uint8_t data[2] = { 0x80, offset }; + error = maa_i2c_address (m_i2c_lcd_control, m_lcd_control_address); + error = maa_i2c_write (m_i2c_lcd_control, data, 2); - return error; + return error; } maa_result_t Jhd1313m1::clear () { - return cmd (m_i2c_lcd_control, LCD_CLEARDISPLAY); + return cmd (m_i2c_lcd_control, LCD_CLEARDISPLAY); } maa_result_t Jhd1313m1::home () { - return cmd (m_i2c_lcd_control, LCD_RETURNHOME); + return cmd (m_i2c_lcd_control, LCD_RETURNHOME); } /* @@ -119,22 +119,22 @@ Jhd1313m1::home () { */ maa_result_t Jhd1313m1::setReg (maa_i2c_context ctx, int deviceAdress, int addr, uint8_t value) { - maa_result_t error = MAA_SUCCESS; + maa_result_t error = MAA_SUCCESS; - uint8_t data[2] = { addr, value }; - error = maa_i2c_address (ctx, deviceAdress); - error = maa_i2c_write (ctx, data, 2); + uint8_t data[2] = { addr, value }; + error = maa_i2c_address (ctx, deviceAdress); + error = maa_i2c_write (ctx, data, 2); - return error; + return error; } maa_result_t Jhd1313m1::cmd (maa_i2c_context ctx, uint8_t value) { - maa_result_t error = MAA_SUCCESS; + maa_result_t error = MAA_SUCCESS; - uint8_t data[2] = { 0x80, value }; - error = maa_i2c_address (ctx, m_lcd_control_address); - error = maa_i2c_write (ctx, data, 2); + uint8_t data[2] = { 0x80, value }; + error = maa_i2c_address (ctx, m_lcd_control_address); + error = maa_i2c_write (ctx, data, 2); - return error; + return error; } diff --git a/src/lcd/jhd1313m1.h b/src/lcd/jhd1313m1.h index 3269b2c4..436e5c9b 100644 --- a/src/lcd/jhd1313m1.h +++ b/src/lcd/jhd1313m1.h @@ -30,19 +30,19 @@ namespace upm { class Jhd1313m1 : public IICLcd { public: - Jhd1313m1 (int bus, int lcdAddress, int rgbAddress); - ~Jhd1313m1 (); - maa_result_t write (std::string msg); - maa_result_t setCursor (int row, int column); - maa_result_t clear (); - maa_result_t home (); + Jhd1313m1 (int bus, int lcdAddress, int rgbAddress); + ~Jhd1313m1 (); + maa_result_t write (std::string msg); + maa_result_t setCursor (int row, int column); + maa_result_t clear (); + maa_result_t home (); - private: - maa_result_t cmd (maa_i2c_context ctx, uint8_t value); - maa_result_t setReg (maa_i2c_context ctx, int deviceAdress, int addr, uint8_t data); + private: + maa_result_t cmd (maa_i2c_context ctx, uint8_t value); + maa_result_t setReg (maa_i2c_context ctx, int deviceAdress, int addr, uint8_t data); - int m_rgb_address; - maa_i2c_context m_i2c_lcd_rgb; + int m_rgb_address; + maa_i2c_context m_i2c_lcd_rgb; }; } diff --git a/src/lcd/lcm1602.cxx b/src/lcd/lcm1602.cxx index a9f30c86..6ec488b4 100644 --- a/src/lcd/lcm1602.cxx +++ b/src/lcd/lcm1602.cxx @@ -33,10 +33,10 @@ using namespace upm; Lcm1602::Lcm1602(int bus_in, int addr_in) : IICLcd (bus_in, addr_in) { - maa_result_t error = MAA_SUCCESS; + maa_result_t error = MAA_SUCCESS; - usleep(50000); - expandWrite(LCD_BACKLIGHT); + usleep(50000); + expandWrite(LCD_BACKLIGHT); usleep(100000); write4bits(0x03 << 4); @@ -61,7 +61,7 @@ Lcm1602::Lcm1602(int bus_in, int addr_in) : IICLcd (bus_in, addr_in) { } Lcm1602::~Lcm1602 () { - + } /* @@ -71,7 +71,7 @@ Lcm1602::~Lcm1602 () { */ maa_result_t Lcm1602::write (std::string msg) { - maa_result_t error = MAA_SUCCESS; + maa_result_t error = MAA_SUCCESS; for (std::string::size_type i = 0; i < msg.size(); ++i) { error = send (msg[i], LCD_RS); } @@ -80,22 +80,22 @@ Lcm1602::write (std::string msg) { maa_result_t Lcm1602::setCursor (int row, int column) { - maa_result_t error = MAA_SUCCESS; + maa_result_t error = MAA_SUCCESS; - int row_addr[] = { 0x80, 0xc0, 0x14, 0x54}; - uint8_t offset = ((column % 16) + row_addr[row]); + int row_addr[] = { 0x80, 0xc0, 0x14, 0x54}; + uint8_t offset = ((column % 16) + row_addr[row]); - return send (LCD_SETDDRAMADDR | offset, 0); + return send (LCD_SETDDRAMADDR | offset, 0); } maa_result_t Lcm1602::clear () { - return send(LCD_CLEARDISPLAY, 0); + return send(LCD_CLEARDISPLAY, 0); } maa_result_t Lcm1602::home () { - return send(LCD_RETURNHOME, 0); + return send(LCD_RETURNHOME, 0); } /* @@ -105,7 +105,7 @@ Lcm1602::home () { */ maa_result_t Lcm1602::send (uint8_t value, int mode) { - maa_result_t ret = MAA_SUCCESS; + maa_result_t ret = MAA_SUCCESS; uint8_t h = value & 0xf0; uint8_t l = (value << 4) & 0xf0; ret = write4bits(h | mode); diff --git a/src/lcd/lcm1602.h b/src/lcd/lcm1602.h index e419ebe7..100614cd 100644 --- a/src/lcd/lcm1602.h +++ b/src/lcd/lcm1602.h @@ -33,23 +33,23 @@ namespace upm { class Lcm1602 : public IICLcd { - public: - /** LCM1602 Constructor. - * Calls MAA initialisation functions. - * @param bus i2c bus to use - * @param address the slave address the lcd is registered on. - */ - Lcm1602(int bus, int address); - ~Lcm1602(); - maa_result_t write (std::string msg); - maa_result_t setCursor (int row, int column); - maa_result_t clear (); - maa_result_t home (); + public: + /** LCM1602 Constructor. + * Calls MAA initialisation functions. + * @param bus i2c bus to use + * @param address the slave address the lcd is registered on. + */ + Lcm1602(int bus, int address); + ~Lcm1602(); + maa_result_t write (std::string msg); + maa_result_t setCursor (int row, int column); + maa_result_t clear (); + maa_result_t home (); - private : - maa_result_t send (uint8_t value, int mode); - maa_result_t write4bits(uint8_t value); - maa_result_t expandWrite(uint8_t value); - maa_result_t pulseEnable(uint8_t value); - }; + private : + maa_result_t send (uint8_t value, int mode); + maa_result_t write4bits(uint8_t value); + maa_result_t expandWrite(uint8_t value); + maa_result_t pulseEnable(uint8_t value); + }; } diff --git a/src/ledbar/my9221.cxx b/src/ledbar/my9221.cxx index 2bdd17c9..03197637 100644 --- a/src/ledbar/my9221.cxx +++ b/src/ledbar/my9221.cxx @@ -31,42 +31,42 @@ using namespace upm; MY9221::MY9221 (uint8_t di, uint8_t dcki) { - maa_result_t error = MAA_SUCCESS; - maa_init(); + maa_result_t error = MAA_SUCCESS; + maa_init(); - // init clock context - m_clkPinCtx = maa_gpio_init(dcki); - if (m_clkPinCtx == NULL) { + // init clock context + m_clkPinCtx = maa_gpio_init(dcki); + if (m_clkPinCtx == NULL) { fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", dcki); - exit(1); - } - // init data context - m_dataPinCtx = maa_gpio_init(di); - if (m_dataPinCtx == NULL) { + exit(1); + } + // init data context + m_dataPinCtx = maa_gpio_init(di); + if (m_dataPinCtx == NULL) { fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", di); - exit(1); - } - - // set direction (out) - error = maa_gpio_dir(m_clkPinCtx, MAA_GPIO_OUT); + exit(1); + } + + // set direction (out) + error = maa_gpio_dir(m_clkPinCtx, MAA_GPIO_OUT); if (error != MAA_SUCCESS) { maa_result_print(error); } - // set direction (out) - error = maa_gpio_dir(m_dataPinCtx, MAA_GPIO_OUT); + // set direction (out) + error = maa_gpio_dir(m_dataPinCtx, MAA_GPIO_OUT); if (error != MAA_SUCCESS) { maa_result_print(error); } } MY9221::~MY9221() { - maa_result_t error = MAA_SUCCESS; - error = maa_gpio_close (m_dataPinCtx); + maa_result_t error = MAA_SUCCESS; + error = maa_gpio_close (m_dataPinCtx); if (error != MAA_SUCCESS) { maa_result_print(error); } - error = maa_gpio_close (m_clkPinCtx); + error = maa_gpio_close (m_clkPinCtx); if (error != MAA_SUCCESS) { maa_result_print(error); } @@ -74,12 +74,12 @@ MY9221::~MY9221() { maa_result_t MY9221::setBarLevel (uint8_t level) { - if (level > 10) { - return MAA_ERROR_INVALID_PARAMETER; - } + if (level > 10) { + return MAA_ERROR_INVALID_PARAMETER; + } - send16bitBlock (CMDMODE); - for(uint8_t block_idx = 0; block_idx < 12; block_idx++) { + send16bitBlock (CMDMODE); + for(uint8_t block_idx = 0; block_idx < 12; block_idx++) { uint32_t state = (block_idx < level) ? BIT_HIGH : BIT_LOW; send16bitBlock (state); } @@ -88,32 +88,32 @@ MY9221::setBarLevel (uint8_t level) { maa_result_t MY9221::lockData () { - maa_result_t error = MAA_SUCCESS; - error = maa_gpio_write (m_dataPinCtx, LOW); - usleep(100); - - for(int idx = 0; idx < 4; idx++) { - error = maa_gpio_write (m_dataPinCtx, HIGH); - error = maa_gpio_write (m_dataPinCtx, LOW); + maa_result_t error = MAA_SUCCESS; + error = maa_gpio_write (m_dataPinCtx, LOW); + usleep(100); + + for(int idx = 0; idx < 4; idx++) { + error = maa_gpio_write (m_dataPinCtx, HIGH); + error = maa_gpio_write (m_dataPinCtx, LOW); } } maa_result_t MY9221::send16bitBlock (short data) { - maa_result_t error = MAA_SUCCESS; - for (uint8_t bit_idx = 0; bit_idx < MAX_BIT_PER_BLOCK; bit_idx++) { - uint32_t state = (data & 0x8000) ? HIGH : LOW; - error = maa_gpio_write (m_dataPinCtx, state); - state = maa_gpio_read (m_clkPinCtx); + maa_result_t error = MAA_SUCCESS; + for (uint8_t bit_idx = 0; bit_idx < MAX_BIT_PER_BLOCK; bit_idx++) { + uint32_t state = (data & 0x8000) ? HIGH : LOW; + error = maa_gpio_write (m_dataPinCtx, state); + state = maa_gpio_read (m_clkPinCtx); - if (state) { - state = LOW; - } else { - state = HIGH; - } + if (state) { + state = LOW; + } else { + state = HIGH; + } - error = maa_gpio_write (m_clkPinCtx, state); + error = maa_gpio_write (m_clkPinCtx, state); - data <<= 1; - } + data <<= 1; + } } diff --git a/src/ledbar/my9221.h b/src/ledbar/my9221.h index 4850275a..87fcecc9 100644 --- a/src/ledbar/my9221.h +++ b/src/ledbar/my9221.h @@ -27,32 +27,32 @@ #include #include -#define MAX_BIT_PER_BLOCK 16 -#define CMDMODE 0x0000 -#define BIT_HIGH 0x00ff -#define BIT_LOW 0x0000 +#define MAX_BIT_PER_BLOCK 16 +#define CMDMODE 0x0000 +#define BIT_HIGH 0x00ff +#define BIT_LOW 0x0000 -#define HIGH 1 -#define LOW 0 +#define HIGH 1 +#define LOW 0 namespace upm { class MY9221 { public: - MY9221 (uint8_t di, uint8_t dcki); - ~MY9221 (); - maa_result_t setBarLevel (uint8_t level); - std::string name() + MY9221 (uint8_t di, uint8_t dcki); + ~MY9221 (); + maa_result_t setBarLevel (uint8_t level); + std::string name() { return m_name; } - private: - maa_result_t lockData (); - maa_result_t send16bitBlock (short data); + private: + maa_result_t lockData (); + maa_result_t send16bitBlock (short data); - std::string m_name; - maa_gpio_context m_clkPinCtx; - maa_gpio_context m_dataPinCtx; + std::string m_name; + maa_gpio_context m_clkPinCtx; + maa_gpio_context m_dataPinCtx; }; } diff --git a/src/nrf24l01/nrf24l01.cxx b/src/nrf24l01/nrf24l01.cxx index fc9c5ab3..5be416e7 100644 --- a/src/nrf24l01/nrf24l01.cxx +++ b/src/nrf24l01/nrf24l01.cxx @@ -31,21 +31,21 @@ using namespace upm; NRF24l01::NRF24l01 (uint8_t cs) { - maa_init(); - nrfInitModule (cs, 8); + maa_init(); + nrfInitModule (cs, 8); } NRF24l01::~NRF24l01 () { - maa_result_t error = MAA_SUCCESS; - error = maa_spi_stop(m_spi); - if (error != MAA_SUCCESS) { - maa_result_print(error); - } - error = maa_gpio_close (m_cePinCtx); + maa_result_t error = MAA_SUCCESS; + error = maa_spi_stop(m_spi); if (error != MAA_SUCCESS) { maa_result_print(error); } - error = maa_gpio_close (m_csnPinCtx); + error = maa_gpio_close (m_cePinCtx); + if (error != MAA_SUCCESS) { + maa_result_print(error); + } + error = maa_gpio_close (m_csnPinCtx); if (error != MAA_SUCCESS) { maa_result_print(error); } @@ -53,268 +53,268 @@ NRF24l01::~NRF24l01 () { void NRF24l01::nrfInitModule (uint8_t chip_select, uint8_t chip_enable) { - maa_result_t error = MAA_SUCCESS; + maa_result_t error = MAA_SUCCESS; - m_csn = chip_select; - m_ce = chip_enable; - m_channel = 1; + m_csn = chip_select; + m_ce = chip_enable; + m_channel = 1; - m_csnPinCtx = maa_gpio_init (m_csn); - if (m_csnPinCtx == NULL) { + m_csnPinCtx = maa_gpio_init (m_csn); + if (m_csnPinCtx == NULL) { fprintf (stderr, "Are you sure that pin%d you requested is valid on your platform?", m_csn); - exit (1); - } - - m_cePinCtx = maa_gpio_init (m_ce); - if (m_cePinCtx == NULL) { + exit (1); + } + + m_cePinCtx = maa_gpio_init (m_ce); + if (m_cePinCtx == NULL) { fprintf (stderr, "Are you sure that pin%d you requested is valid on your platform?", m_ce); - exit (1); - } - - error = maa_gpio_dir (m_csnPinCtx, MAA_GPIO_OUT); + exit (1); + } + + error = maa_gpio_dir (m_csnPinCtx, MAA_GPIO_OUT); if (error != MAA_SUCCESS) { maa_result_print (error); } - error = maa_gpio_dir (m_cePinCtx, MAA_GPIO_OUT); + error = maa_gpio_dir (m_cePinCtx, MAA_GPIO_OUT); if (error != MAA_SUCCESS) { maa_result_print (error); } - - nrfCELow (); - m_spi = maa_spi_init (0); + + nrfCELow (); + m_spi = maa_spi_init (0); } void NRF24l01::nrfConfigModule() { - /* Set RF channel */ - nrfConfigRegister (RF_CH, m_channel); + /* Set RF channel */ + nrfConfigRegister (RF_CH, m_channel); - /* Set length of incoming payload */ - nrfConfigRegister (RX_PW_P0, m_payload); - nrfConfigRegister (RX_PW_P1, m_payload); - /* Set length of incoming payload for broadcast */ - nrfConfigRegister (RX_PW_P2, m_payload); - - /* Start receiver */ - nrfPowerUpRX (); - nrfFlushRX (); + /* Set length of incoming payload */ + nrfConfigRegister (RX_PW_P0, m_payload); + nrfConfigRegister (RX_PW_P1, m_payload); + /* Set length of incoming payload for broadcast */ + nrfConfigRegister (RX_PW_P2, m_payload); + + /* Start receiver */ + nrfPowerUpRX (); + nrfFlushRX (); } /* Clocks only one byte into the given MiRF register */ void NRF24l01::nrfConfigRegister(uint8_t reg, uint8_t value) { - nrfCSOn (); - maa_spi_write (m_spi, W_REGISTER | (REGISTER_MASK & reg)); - maa_spi_write (m_spi, value); - nrfCSOff (); + nrfCSOn (); + maa_spi_write (m_spi, W_REGISTER | (REGISTER_MASK & reg)); + maa_spi_write (m_spi, value); + nrfCSOff (); } void NRF24l01::nrfPowerUpRX() { - m_ptx = 0; - nrfCELow(); - nrfConfigRegister(CONFIG, mirf_CONFIG | ( (1< /* Memory Map */ -#define CONFIG 0x00 -#define EN_AA 0x01 -#define EN_RXADDR 0x02 -#define SETUP_AW 0x03 -#define SETUP_RETR 0x04 -#define RF_CH 0x05 -#define RF_SETUP 0x06 -#define STATUS 0x07 -#define OBSERVE_TX 0x08 -#define CD 0x09 -#define RX_ADDR_P0 0x0A -#define RX_ADDR_P1 0x0B -#define RX_ADDR_P2 0x0C -#define RX_ADDR_P3 0x0D -#define RX_ADDR_P4 0x0E -#define RX_ADDR_P5 0x0F -#define TX_ADDR 0x10 -#define RX_PW_P0 0x11 -#define RX_PW_P1 0x12 -#define RX_PW_P2 0x13 -#define RX_PW_P3 0x14 -#define RX_PW_P4 0x15 -#define RX_PW_P5 0x16 -#define FIFO_STATUS 0x17 +#define CONFIG 0x00 +#define EN_AA 0x01 +#define EN_RXADDR 0x02 +#define SETUP_AW 0x03 +#define SETUP_RETR 0x04 +#define RF_CH 0x05 +#define RF_SETUP 0x06 +#define STATUS 0x07 +#define OBSERVE_TX 0x08 +#define CD 0x09 +#define RX_ADDR_P0 0x0A +#define RX_ADDR_P1 0x0B +#define RX_ADDR_P2 0x0C +#define RX_ADDR_P3 0x0D +#define RX_ADDR_P4 0x0E +#define RX_ADDR_P5 0x0F +#define TX_ADDR 0x10 +#define RX_PW_P0 0x11 +#define RX_PW_P1 0x12 +#define RX_PW_P2 0x13 +#define RX_PW_P3 0x14 +#define RX_PW_P4 0x15 +#define RX_PW_P5 0x16 +#define FIFO_STATUS 0x17 /* Bit Mnemonics */ -#define MASK_RX_DR 6 -#define MASK_TX_DS 5 -#define MASK_MAX_RT 4 -#define EN_CRC 3 -#define CRCO 2 -#define PWR_UP 1 -#define PRIM_RX 0 -#define ENAA_P5 5 -#define ENAA_P4 4 -#define ENAA_P3 3 -#define ENAA_P2 2 -#define ENAA_P1 1 -#define ENAA_P0 0 -#define ERX_P5 5 -#define ERX_P4 4 -#define ERX_P3 3 -#define ERX_P2 2 -#define ERX_P1 1 -#define ERX_P0 0 -#define AW 0 -#define ARD 4 -#define ARC 0 -#define PLL_LOCK 4 -#define RF_DR 3 -#define RF_PWR 1 -#define LNA_HCURR 0 -#define RX_DR 6 -#define TX_DS 5 -#define MAX_RT 4 -#define RX_P_NO 1 -#define TX_FULL 0 -#define PLOS_CNT 4 -#define ARC_CNT 0 -#define TX_REUSE 6 -#define FIFO_FULL 5 -#define TX_EMPTY 4 -#define RX_FULL 1 -#define RX_EMPTY 0 +#define MASK_RX_DR 6 +#define MASK_TX_DS 5 +#define MASK_MAX_RT 4 +#define EN_CRC 3 +#define CRCO 2 +#define PWR_UP 1 +#define PRIM_RX 0 +#define ENAA_P5 5 +#define ENAA_P4 4 +#define ENAA_P3 3 +#define ENAA_P2 2 +#define ENAA_P1 1 +#define ENAA_P0 0 +#define ERX_P5 5 +#define ERX_P4 4 +#define ERX_P3 3 +#define ERX_P2 2 +#define ERX_P1 1 +#define ERX_P0 0 +#define AW 0 +#define ARD 4 +#define ARC 0 +#define PLL_LOCK 4 +#define RF_DR 3 +#define RF_PWR 1 +#define LNA_HCURR 0 +#define RX_DR 6 +#define TX_DS 5 +#define MAX_RT 4 +#define RX_P_NO 1 +#define TX_FULL 0 +#define PLOS_CNT 4 +#define ARC_CNT 0 +#define TX_REUSE 6 +#define FIFO_FULL 5 +#define TX_EMPTY 4 +#define RX_FULL 1 +#define RX_EMPTY 0 /* Instruction Mnemonics */ -#define R_REGISTER 0x00 -#define W_REGISTER 0x20 -#define REGISTER_MASK 0x1F -#define R_RX_PAYLOAD 0x61 -#define W_TX_PAYLOAD 0xA0 -#define FLUSH_TX 0xE1 -#define FLUSH_RX 0xE2 -#define REUSE_TX_PL 0xE3 -#define NOP 0xFF +#define R_REGISTER 0x00 +#define W_REGISTER 0x20 +#define REGISTER_MASK 0x1F +#define R_RX_PAYLOAD 0x61 +#define W_TX_PAYLOAD 0xA0 +#define FLUSH_TX 0xE1 +#define FLUSH_RX 0xE2 +#define REUSE_TX_PL 0xE3 +#define NOP 0xFF /* Nrf24l settings */ -#define mirf_ADDR_LEN 5 -#define mirf_CONFIG ((1<