bitmuster angepasst
This commit is contained in:
parent
8b12507c3b
commit
5401635968
4 changed files with 24 additions and 23 deletions
|
@ -135,6 +135,13 @@ void B15F::delay_us(uint16_t us)
|
|||
std::this_thread::sleep_for(std::chrono::microseconds(us));
|
||||
}
|
||||
|
||||
void B15F::reverse(uint8_t& b)
|
||||
{
|
||||
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
||||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
||||
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/478960
|
||||
std::string B15F::exec(std::string cmd)
|
||||
{
|
||||
|
@ -197,10 +204,7 @@ bool B15F::activateSelfTestMode()
|
|||
}
|
||||
|
||||
bool B15F::digitalWrite0(uint8_t port)
|
||||
{
|
||||
|
||||
reverse(port);
|
||||
|
||||
{
|
||||
uint8_t rq[] =
|
||||
{
|
||||
RQ_DIGITAL_WRITE_0,
|
||||
|
@ -215,9 +219,6 @@ bool B15F::digitalWrite0(uint8_t port)
|
|||
|
||||
bool B15F::digitalWrite1(uint8_t port)
|
||||
{
|
||||
|
||||
reverse(port);
|
||||
|
||||
uint8_t rq[] =
|
||||
{
|
||||
RQ_DIGITAL_WRITE_1,
|
||||
|
@ -269,6 +270,9 @@ uint8_t B15F::readDipSwitch()
|
|||
|
||||
uint8_t aw;
|
||||
usart.receive(&aw, 0, sizeof(aw));
|
||||
|
||||
reverse(aw); // DIP Schalter muss invertiert werden!
|
||||
|
||||
return aw;
|
||||
}
|
||||
|
||||
|
@ -512,10 +516,3 @@ void B15F::init()
|
|||
std::cout << PRE << "AVR Firmware Version: " << info[0] << " um " << info[1] << " Uhr (" << info[2] << ")"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
void B15F::reverse(uint8_t& b)
|
||||
{
|
||||
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
||||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
||||
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
|
||||
}
|
||||
|
|
|
@ -85,6 +85,13 @@ public:
|
|||
* \param us Verzögerung in Microsekunden
|
||||
*/
|
||||
void delay_us(uint16_t us);
|
||||
|
||||
/**
|
||||
* Invertiert das Bitmuster eines Bytes
|
||||
* z.B.: 10100001 --> 10000101
|
||||
* \param b Byte, das invertiert wird
|
||||
*/
|
||||
void reverse(uint8_t& b);
|
||||
|
||||
/**
|
||||
* Führt ein Befehl auf dieser Maschine aus und liefert stdout zurück
|
||||
|
@ -255,12 +262,6 @@ private:
|
|||
* \throws DriverException
|
||||
*/
|
||||
void init(void);
|
||||
|
||||
/**
|
||||
* Invertiert das Bitmuster eines Bytes
|
||||
* z.B.: 10100001 --> 10000101
|
||||
*/
|
||||
void reverse(uint8_t& b);
|
||||
|
||||
USART usart;
|
||||
static B15F* instance;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue