remote set and get register by address
This commit is contained in:
parent
2c47159df3
commit
2e88b9c980
69 changed files with 1595 additions and 117 deletions
|
@ -330,6 +330,46 @@ bool B15F::pwmSetValue(uint8_t value)
|
|||
return aw == MSG_OK;
|
||||
}
|
||||
|
||||
bool B15F::setRegister(uint8_t adr, uint8_t val)
|
||||
{
|
||||
usart.clearInputBuffer();
|
||||
|
||||
uint8_t rq[] =
|
||||
{
|
||||
RQ_SET_REG,
|
||||
adr,
|
||||
val
|
||||
};
|
||||
|
||||
int n_sent = usart.write_timeout(&rq[0], 0, sizeof(rq), 1000);
|
||||
if(n_sent != sizeof(rq))
|
||||
abort("Sent failed");
|
||||
|
||||
uint8_t byte = usart.readByte();
|
||||
delay_us(10);
|
||||
return byte == val;
|
||||
}
|
||||
|
||||
uint8_t B15F::getRegister(uint8_t adr)
|
||||
{
|
||||
usart.clearInputBuffer();
|
||||
|
||||
uint8_t rq[] =
|
||||
{
|
||||
RQ_GET_REG,
|
||||
adr
|
||||
};
|
||||
|
||||
int n_sent = usart.write_timeout(&rq[0], 0, sizeof(rq), 1000);
|
||||
if(n_sent != sizeof(rq))
|
||||
abort("Sent failed");
|
||||
|
||||
uint8_t aw = usart.readByte();
|
||||
delay_us(10);
|
||||
return aw;
|
||||
}
|
||||
|
||||
|
||||
void B15F::delay_ms(uint16_t ms)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
||||
|
|
|
@ -210,6 +210,22 @@ public:
|
|||
*/
|
||||
bool pwmSetValue(uint8_t value);
|
||||
|
||||
/**
|
||||
* Setzt direkt den Wert eines MCU Registers.
|
||||
* *Wichtig:* bei einer falschen Adresse kann das Board 15 ernsthaften Schaden nehmen!
|
||||
* \param adr Speicheradresse des Registers
|
||||
* \param val Neuer Wert für das Register
|
||||
* \throws DriverException
|
||||
*/
|
||||
bool setRegister(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);
|
||||
|
||||
/*************************/
|
||||
|
||||
|
||||
|
@ -248,9 +264,11 @@ private:
|
|||
constexpr static uint8_t RQ_AA0 = 10;
|
||||
constexpr static uint8_t RQ_AA1 = 11;
|
||||
constexpr static uint8_t RQ_ADC = 12;
|
||||
constexpr static uint8_t RQ_ADC_DAC_STROKE = 13;
|
||||
constexpr static uint8_t RQ_PWM_SET_FREQ = 14;
|
||||
constexpr static uint8_t RQ_PWM_SET_VALUE = 15;
|
||||
constexpr static uint8_t RQ_ADC_DAC_STROKE = 13;
|
||||
constexpr static uint8_t RQ_PWM_SET_FREQ = 14;
|
||||
constexpr static uint8_t RQ_PWM_SET_VALUE = 15;
|
||||
constexpr static uint8_t RQ_SET_REG = 16;
|
||||
constexpr static uint8_t RQ_GET_REG = 17;
|
||||
};
|
||||
|
||||
#endif // B15F_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue