C/C++ Question (CLOSED) rControllino

Johan Schoeman

Expert
Licensed User
Longtime User
I am just being past stupid today and just cannot add the below working Inline C code to rControllino.h and rControllino..cpp. Please assist. I have deleted whatever I have done to add it to the library as whatever I tried just does not work. And I guess the solution is a bit more "complicated" than what I thought. Attached the rControllino.h and rControllino.ccp files in the ZIP

The working Inline C code is as follows:

Inline C code:
#if C
#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;

void initDDRA (B4R::Object* o) {
     DDRA |= o->toULong();
}

void initDDRB (B4R::Object* o) {
     DDRB |= o->toULong();
}

void initDDRC (B4R::Object* o) {
     DDRC |= o->toULong();
}

void initDDRD (B4R::Object* o) {
     DDRD |= o->toULong();
}

void initDDRE (B4R::Object* o) {
     DDRE |= o->toULong();
}

void initDDRF (B4R::Object* o) {
     DDRF |= o->toULong();
}

void initDDRG (B4R::Object* o) {
     DDRG |= o->toULong();
}

void initDDRH (B4R::Object* o) {
     DDRH |= o->toULong();
}

void initDDRJ (B4R::Object* o) {
     DDRJ |= o->toULong();
}

void initDDRK (B4R::Object* o) {
     DDRK |= o->toULong();
}

void initDDRL (B4R::Object* o) {
     DDRL |= o->toULong();
}

void ClearPortA (B4R::Object* o) {
  clear_port(PORTA, o->toULong());
}
void SetPortA (B4R::Object* o) {
  set_port(PORTA, o->toULong());
}

void ClearPortB (B4R::Object* o) {
  clear_port(PORTB, o->toULong());
}
void SetPortB (B4R::Object* o) {
  set_port(PORTB, o->toULong());
}

void ClearPortC (B4R::Object* o) {
  clear_port(PORTC, o->toULong());
}
void SetPortC (B4R::Object* o) {
  set_port(PORTC, o->toULong());
}

void ClearPortD (B4R::Object* o) {
  clear_port(PORTD, o->toULong());
}
void SetPortD (B4R::Object* o) {
  set_port(PORTD, o->toULong());
}

void ClearPortE (B4R::Object* o) {
  clear_port(PORTE, o->toULong());
}
void SetPortE (B4R::Object* o) {
  set_port(PORTE, o->toULong());
}

void ClearPortF (B4R::Object* o) {
  clear_port(PORTF, o->toULong());
}
void SetPortF (B4R::Object* o) {
  set_port(PORTF, o->toULong());
}

void ClearPortG (B4R::Object* o) {
  clear_port(PORTG, o->toULong());
}
void SetPortG (B4R::Object* o) {
  set_port(PORTG, o->toULong());
}

void ClearPortH (B4R::Object* o) {
  clear_port(PORTH, o->toULong());
}
void SetPortH (B4R::Object* o) {
  set_port(PORTH, o->toULong());
}

void ClearPortJ (B4R::Object* o) {
  clear_port(PORTJ, o->toULong());
}
void SetPortJ (B4R::Object* o) {
  set_port(PORTJ, o->toULong());
}

void ClearPortK (B4R::Object* o) {
  clear_port(PORTK, o->toULong());
}
void SetPortK (B4R::Object* o) {
  set_port(PORTK, o->toULong());
}

void ClearPortL (B4R::Object* o) {
  clear_port(PORTL, o->toULong());
}
void SetPortL (B4R::Object* o) {
  set_port(PORTL, o->toULong());
}

#end if

The inline C code is called from the B4R project as (for eg) as follows:

B4R call to inline C code:
    RunNative("initDDRL", 0xff)
    RunNative("initDDRE", 0x80)

I would really like it to be in the library and not as inline C code.

Thanks

Johan
 

Attachments

  • rControllino.zip
    3.6 KB · Views: 108
Top