DeqingSun / ch55xduino

An Arduino-like programming API for the CH55X
GNU Lesser General Public License v2.1
441 stars 86 forks source link

shift registers problem #43

Closed bamboo-master closed 3 years ago

bamboo-master commented 3 years ago

I wanted to use a CH552 and a seven-segment display using a 74hc595 shift registers. On stm8s103f3p6 (sduino) it works fine, but ch552 doesn't even compile. I get errors:

warning 112: function 'shiftOut' implicit declaration
warning 112: function 'shiftOut' implicit declaration
error 101: too many parameters 
error 101: too many parameters 

2021-03-28_18-08-55

If I drop these two lines with "shiftOut", the sketch will compile successfully.

DeqingSun commented 3 years ago

The shiftin and shiftout is not implemented yet. You can use a for loop do it.

DeqingSun commented 3 years ago

@sh4had you may add this function in your sketch to use the shiftout function.

void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
{
 uint8_t i;
 for (i = 0; i < 8; i++) {
 if (bitOrder == LSBFIRST)
 digitalWrite(dataPin, !!(val & (1 << i)));
 else
 digitalWrite(dataPin, !!(val & (1 << (7 - i))));
 digitalWrite(clockPin, HIGH);
 digitalWrite(clockPin, LOW);
 }
}
bamboo-master commented 3 years ago

Thanks! Now everything works.