Hi Erel,
I have some Arduino code that I'd like to port into B4R without using inline or have to build a library wrapper for it. It reads and writes to the Arduino ports in bytes. I looked in the forums and have not found an equivalent or I'm just doing the wrong search term. Here is the Arduino code:
Is there an equivalent code structure (not using bits) in B4R?
I looked into using an HC595 and a SPI port in the future but the hardware is already built and working so I wanted to make the least amount of H/W changes.
Thanks,
Paul
I have some Arduino code that I'd like to port into B4R without using inline or have to build a library wrapper for it. It reads and writes to the Arduino ports in bytes. I looked in the forums and have not found an equivalent or I'm just doing the wrong search term. Here is the Arduino code:
B4X:
// *** Hardware specific defines ***
#define clear_port_bit(reg, bitmask) *reg &= ~bitmask
#define set_port_bit(reg, bitmask) *reg |= bitmask
#define pulse_high(reg, bitmask) clear_port_bit(reg, bitmask); set_port_bit(reg, bitmask);
#define pulse_low(reg, bitmask) set_port_bit(reg, bitmask); clear_port_bit(reg, bitmask);
#define clear_port(port, data) port &= data
#define set_port(port, data) port |= data
// *** Set Data Direction ***
DDRC |= 0x40;
DDRD |= 0x9F;
DDRE |= 0x40;
// *** Set/Clear Port Data ***
clear_port(PORTC, 0xBF); // -->> PORTC &= 0xBF;
clear_port(PORTD, 0x60); // -->> PORTD &= 0x60;
clear_port(PORTE, 0xBF); // -->> PORTE &= 0xBF;
set_port(PORTC, 0x0F); // -->> PORTC |= 0x0F;
set_port(PORTD, 0X40); // -->> PORTD |= 0x40;
set_port(PORTE, 0xB0); // -->> PORTE |= 0xB0;
Is there an equivalent code structure (not using bits) in B4R?
I looked into using an HC595 and a SPI port in the future but the hardware is already built and working so I wanted to make the least amount of H/W changes.
Thanks,
Paul
Last edited: