register zugriff verschönert
This commit is contained in:
parent
78e8ab5d1c
commit
72c34b6ba4
3 changed files with 25 additions and 21 deletions
|
@ -393,14 +393,14 @@ bool B15F::pwmSetValue(uint8_t value)
|
|||
return aw == MSG_OK;
|
||||
}
|
||||
|
||||
bool B15F::setRegister(uint8_t adr, uint8_t val)
|
||||
bool B15F::setRegister(volatile uint8_t* adr, uint8_t val)
|
||||
{
|
||||
usart.clearInputBuffer();
|
||||
|
||||
uint8_t rq[] =
|
||||
{
|
||||
RQ_SET_REG,
|
||||
adr,
|
||||
static_cast<uint8_t>(reinterpret_cast<size_t>(adr)),
|
||||
val
|
||||
};
|
||||
|
||||
|
@ -411,14 +411,14 @@ bool B15F::setRegister(uint8_t adr, uint8_t val)
|
|||
return aw == val;
|
||||
}
|
||||
|
||||
uint8_t B15F::getRegister(uint8_t adr)
|
||||
uint8_t B15F::getRegister(volatile uint8_t* adr)
|
||||
{
|
||||
usart.clearInputBuffer();
|
||||
|
||||
uint8_t rq[] =
|
||||
{
|
||||
RQ_GET_REG,
|
||||
adr
|
||||
static_cast<uint8_t>(reinterpret_cast<size_t>(adr))
|
||||
};
|
||||
|
||||
usart.transmit(&rq[0], 0, sizeof(rq));
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
#include "driverexception.h"
|
||||
#include "timeoutexception.h"
|
||||
|
||||
// wichtig für die Register-Zugriffe
|
||||
#define _AVR_IO_H_ 1 // Erzwinge die Inklusion
|
||||
#include "/usr/lib/avr/include/avr/sfr_defs.h"
|
||||
#include "/usr/lib/avr/include/avr/iom1284p.h"
|
||||
|
||||
typedef std::function<void(std::exception&)> errorhandler_t;
|
||||
|
||||
|
||||
|
@ -217,14 +222,14 @@ public:
|
|||
* \param val Neuer Wert für das Register
|
||||
* \throws DriverException
|
||||
*/
|
||||
bool setRegister(uint8_t adr, uint8_t val);
|
||||
bool setRegister(volatile uint8_t* adr, uint8_t val);
|
||||
|
||||
/**
|
||||
* Liefert den Wert eines MCU Registers.
|
||||
* \param adr Speicheradresse des Registers
|
||||
* \throws DriverException
|
||||
*/
|
||||
uint8_t getRegister(uint8_t adr);
|
||||
uint8_t getRegister(volatile uint8_t* adr);
|
||||
|
||||
/*************************/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue