added mem 16
This commit is contained in:
parent
fbf95edb58
commit
a76321eb6b
13
README.md
13
README.md
|
@ -6,15 +6,18 @@ Die Projekt-Dokumentation befindet sich unter [github pages](https://devfix.gith
|
|||
## TODO / Ideen
|
||||
- [X] CLI: Exception catchen, set global error message, raise SIGINT --> ncurses wird richtig beendet
|
||||
- [ ] Monitor: Refresh visualisieren, z.B. - / - \ |
|
||||
- [ ] Main Menu: Informationen ergänzen
|
||||
- [x] Main Menu: Informationen ergänzen
|
||||
- [X] Selbsttest bei discard richtig beenden (momentan wird wahrscheinlich WDT angeschmissen, besser global bool für selbsttest-loop)
|
||||
- [x] Lizenz
|
||||
- [x] gitignore checken
|
||||
- [x] readme schreiben
|
||||
- [ ] CLI: Farbe?
|
||||
- [ ] globale strings / msg klasse für treiber, ui (z.B. B15F info)
|
||||
- [ ] drv: requests als array organisieren
|
||||
- [ ] drv/usart überarbeiten, evtl iotl select
|
||||
- [ ] dreipol dil schalter ansprechbar machen
|
||||
- [x] drv: requests als array organisieren
|
||||
- [x] drv/usart überarbeiten, evtl iotl select
|
||||
- [ ] die vier buttons ansprechbar machen
|
||||
- [ ] Kommentieren
|
||||
- [ ] Server ansteuert
|
||||
- [ ] Interrupt Counter
|
||||
- [ ] mem16 testen
|
||||
- [ ] autocheck request size
|
||||
|
||||
|
|
|
@ -423,14 +423,15 @@ bool B15F::pwmSetValue(uint8_t value)
|
|||
return aw == MSG_OK;
|
||||
}
|
||||
|
||||
bool B15F::setRegister(volatile uint8_t* adr, uint8_t val)
|
||||
bool B15F::setMem8(volatile uint16_t* adr, uint8_t val)
|
||||
{
|
||||
usart.clearInputBuffer();
|
||||
|
||||
uint8_t rq[] =
|
||||
{
|
||||
RQ_SET_REGISTER,
|
||||
static_cast<uint8_t>(reinterpret_cast<size_t>(adr)),
|
||||
RQ_SET_MEM_8,
|
||||
static_cast<uint8_t >(reinterpret_cast<size_t>(adr) & 0xFF),
|
||||
static_cast<uint8_t >(reinterpret_cast<size_t>(adr) >> 8),
|
||||
val
|
||||
};
|
||||
|
||||
|
@ -441,14 +442,15 @@ bool B15F::setRegister(volatile uint8_t* adr, uint8_t val)
|
|||
return aw == val;
|
||||
}
|
||||
|
||||
uint8_t B15F::getRegister(volatile uint8_t* adr)
|
||||
uint8_t B15F::getMem8(volatile uint16_t* adr)
|
||||
{
|
||||
usart.clearInputBuffer();
|
||||
|
||||
uint8_t rq[] =
|
||||
{
|
||||
RQ_GET_REGISTER,
|
||||
static_cast<uint8_t>(reinterpret_cast<size_t>(adr))
|
||||
RQ_GET_MEM_8,
|
||||
static_cast<uint8_t >(reinterpret_cast<size_t>(adr) & 0xFF),
|
||||
static_cast<uint8_t >(reinterpret_cast<size_t>(adr) >> 8)
|
||||
};
|
||||
|
||||
usart.transmit(&rq[0], 0, sizeof(rq));
|
||||
|
@ -458,6 +460,54 @@ uint8_t B15F::getRegister(volatile uint8_t* adr)
|
|||
return aw;
|
||||
}
|
||||
|
||||
bool B15F::setMem16(volatile uint16_t* adr, uint16_t val)
|
||||
{
|
||||
usart.clearInputBuffer();
|
||||
|
||||
uint8_t rq[] =
|
||||
{
|
||||
RQ_SET_MEM_16,
|
||||
static_cast<uint8_t >(reinterpret_cast<size_t>(adr) & 0xFF),
|
||||
static_cast<uint8_t >(reinterpret_cast<size_t>(adr) >> 8),
|
||||
static_cast<uint8_t >(val & 0xFF),
|
||||
static_cast<uint8_t >(val >> 8)
|
||||
};
|
||||
|
||||
usart.transmit(&rq[0], 0, sizeof(rq));
|
||||
|
||||
uint16_t aw;
|
||||
usart.receive(reinterpret_cast<uint8_t *>(&aw), 0, sizeof(aw));
|
||||
return aw == val;
|
||||
}
|
||||
|
||||
uint16_t B15F::getMem16(volatile uint16_t* adr)
|
||||
{
|
||||
usart.clearInputBuffer();
|
||||
|
||||
uint8_t rq[] =
|
||||
{
|
||||
RQ_GET_MEM_16,
|
||||
static_cast<uint8_t >(reinterpret_cast<size_t>(adr) & 0xFF),
|
||||
static_cast<uint8_t >(reinterpret_cast<size_t>(adr) >> 8)
|
||||
};
|
||||
|
||||
usart.transmit(&rq[0], 0, sizeof(rq));
|
||||
|
||||
uint16_t aw;
|
||||
usart.receive(reinterpret_cast<uint8_t *>(&aw), 0, sizeof(aw));
|
||||
return aw;
|
||||
}
|
||||
|
||||
bool B15F::setRegister(volatile uint8_t* adr, uint8_t val)
|
||||
{
|
||||
return setMem8(reinterpret_cast<volatile uint16_t*>(adr), val);
|
||||
}
|
||||
|
||||
uint8_t B15F::getRegister(volatile uint8_t* adr)
|
||||
{
|
||||
return getMem8(reinterpret_cast<volatile uint16_t*>(adr));
|
||||
}
|
||||
|
||||
/*************************/
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <sys/ioctl.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include "../../../firmware/requests.h"
|
||||
#include "requests.h"
|
||||
#include "usart.h"
|
||||
#include "driverexception.h"
|
||||
#include "timeoutexception.h"
|
||||
|
@ -223,17 +223,61 @@ public:
|
|||
bool pwmSetValue(uint8_t value);
|
||||
|
||||
/**
|
||||
* Setzt direkt den Wert eines MCU Registers.
|
||||
* Setzt direkt den Wert einer MCU Speicherzelle der Größe 8 Bit.
|
||||
* Diese kann ein Register oder RAM-Daten sein.
|
||||
* *Wichtig:* bei einer falschen Adresse kann das Board 15 ernsthaften Schaden nehmen!
|
||||
* \param adr Speicheradresse des Registers
|
||||
* \param adr Speicheradresse
|
||||
* \param val Neuer Wert für die Zelle
|
||||
* \return true, falls Vorgang erfolgreich
|
||||
* \throws DriverException
|
||||
*/
|
||||
bool setMem8(volatile uint16_t* adr, uint8_t val);
|
||||
|
||||
/**
|
||||
* Liefert den Wert einer MCU Speicherzelle der Größe 8 Bit.
|
||||
* Diese kann ein Register oder RAM-Daten sein.
|
||||
* \param adr Speicheradresse
|
||||
* \return Wert der Speicherzelle
|
||||
* \throws DriverException
|
||||
*/
|
||||
uint8_t getMem8(volatile uint16_t* adr);
|
||||
|
||||
/**
|
||||
* Setzt direkt den Wert einer MCU Speicherzelle der Größe 16 Bit.
|
||||
* Diese kann ein Register oder RAM-Daten sein.
|
||||
* *Wichtig:* bei einer falschen Adresse kann das Board 15 ernsthaften Schaden nehmen!
|
||||
* \param adr Speicheradresse
|
||||
* \param val Neuer Wert für die Zelle
|
||||
* \return true, falls Vorgang erfolgreich
|
||||
* \throws DriverException
|
||||
*/
|
||||
bool setMem16(volatile uint16_t* adr, uint16_t val);
|
||||
|
||||
/**
|
||||
* Liefert den Wert einer MCU Speicherzelle der Größe 16 Bit.
|
||||
* Diese kann ein Register oder RAM-Daten sein.
|
||||
* \param adr Speicheradresse
|
||||
* \return Wert der Speicherzelle
|
||||
* \throws DriverException
|
||||
*/
|
||||
uint16_t getMem16(volatile uint16_t* adr);
|
||||
|
||||
/**
|
||||
* Setzt direkt den Wert eines 8-Bit MCU Registers.
|
||||
* Diese Funktion arbeitet analog zu setMem8(), jedoch mit einer 8-Bit Adresse.
|
||||
* *Wichtig:* bei einer falschen Adresse kann das Board 15 ernsthaften Schaden nehmen!
|
||||
* \param adr Speicheradresse
|
||||
* \param val Neuer Wert für das Register
|
||||
* \return true, falls Vorgang erfolgreich
|
||||
* \throws DriverException
|
||||
*/
|
||||
bool setRegister(volatile uint8_t* adr, uint8_t val);
|
||||
|
||||
/**
|
||||
* Liefert den Wert eines MCU Registers.
|
||||
* \param adr Speicheradresse des Registers
|
||||
* Liefert den Wert eines 8-Bit MCU Registers.
|
||||
* Diese Funktion arbeitet analog zu getMem8(), jedoch mit einer 8-Bit Adresse.
|
||||
* \param adr Speicheradresse
|
||||
* \return Wert des Registers
|
||||
* \throws DriverException
|
||||
*/
|
||||
uint8_t getRegister(volatile uint8_t* adr);
|
||||
|
|
|
@ -17,8 +17,10 @@ constexpr static uint8_t RQ_ANALOG_READ = 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_SET_REGISTER = 16;
|
||||
constexpr static uint8_t RQ_GET_REGISTER = 17;
|
||||
constexpr static uint8_t RQ_SET_MEM_8 = 16;
|
||||
constexpr static uint8_t RQ_GET_MEM_8 = 17;
|
||||
constexpr static uint8_t RQ_SET_MEM_16 = 18;
|
||||
constexpr static uint8_t RQ_GET_MEM_16 = 19;
|
||||
|
||||
uint8_t const rq_len[] = {
|
||||
1 /* RQ_DISCARD */,
|
||||
|
@ -37,8 +39,10 @@ uint8_t const rq_len[] = {
|
|||
1 /* RQ_ADC_DAC_STROKE */ + 1 /* channel a */ + 1 /* channel b */ + 1 /* start low */ + 1 /* start high */ + 1 /* delta low */ + 1 /* delta high */ + 1 /* count low */ + 1 /* count high */,
|
||||
1 /* RQ_PWM_SET_FREQ */ + 1 /* freq low low */ + 1 /* freq low high */ + 1 /* freq high low */ + 1 /* freq high high */,
|
||||
1 /* RQ_PWM_SET_VALUE */ + 1 /* pwm value */,
|
||||
1 /* RQ_SET_REGISTER */ + 1 /* register address*/ + 1 /* register value */,
|
||||
1 /* RQ_GET_REGISTER */ + 1 /* register address*/,
|
||||
1 /* RQ_SET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value (8-bit) */,
|
||||
1 /* RQ_GET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */,
|
||||
1 /* RQ_SET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value low */ + 1 /* memory value high */,
|
||||
1 /* RQ_GET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */,
|
||||
};
|
||||
|
||||
#endif // REQUESTS_H
|
|
@ -71,12 +71,12 @@ void handleRequest()
|
|||
rqPwmSetValue();
|
||||
break;
|
||||
|
||||
case RQ_SET_REGISTER:
|
||||
rqSetRegister();
|
||||
case RQ_SET_MEM_8:
|
||||
rqSetMem8();
|
||||
break;
|
||||
|
||||
case RQ_GET_REGISTER:
|
||||
rqGetRegister();
|
||||
case RQ_GET_MEM_8:
|
||||
rqGetMem8();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -253,23 +253,43 @@ void rqPwmSetValue()
|
|||
usart.flush();
|
||||
}
|
||||
|
||||
void rqSetRegister()
|
||||
void rqSetMem8()
|
||||
{
|
||||
usart.initTX();
|
||||
uint16_t reg = usart.readByte();
|
||||
uint16_t val = usart.readByte();
|
||||
uint16_t reg = usart.readInt();
|
||||
uint8_t val = usart.readByte();
|
||||
|
||||
(*(volatile uint8_t *) reg) = val;
|
||||
usart.writeByte((*(volatile uint8_t *) reg));
|
||||
usart.flush();
|
||||
}
|
||||
|
||||
void rqGetRegister()
|
||||
void rqGetMem8()
|
||||
{
|
||||
usart.initTX();
|
||||
uint16_t reg = usart.readByte();
|
||||
uint16_t reg = usart.readInt();
|
||||
|
||||
usart.writeByte((*(volatile uint8_t *) reg));
|
||||
usart.flush();
|
||||
}
|
||||
|
||||
void rqSetMem16()
|
||||
{
|
||||
usart.initTX();
|
||||
uint16_t reg = usart.readInt();
|
||||
uint16_t val = usart.readInt();
|
||||
|
||||
(*(volatile uint16_t *) reg) = val;
|
||||
usart.writeInt((*(volatile uint16_t *) reg));
|
||||
usart.flush();
|
||||
}
|
||||
|
||||
void rqGetMem16()
|
||||
{
|
||||
usart.initTX();
|
||||
uint16_t reg = usart.readInt();
|
||||
|
||||
usart.writeInt((*(volatile uint16_t *) reg));
|
||||
usart.flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define REQUEST_HANDLERS_H
|
||||
|
||||
#include <avr/wdt.h>
|
||||
#include "requests.h"
|
||||
#include "../control/src/drv/requests.h"
|
||||
#include "global_vars.h"
|
||||
#include "selftest.h"
|
||||
#include "boardinfo.h"
|
||||
|
@ -30,7 +30,7 @@ void rqAnalogRead(void);
|
|||
void rqAdcDacStroke(void);
|
||||
void rqPwmSetFreq(void);
|
||||
void rqPwmSetValue(void);
|
||||
void rqSetRegister(void);
|
||||
void rqGetRegister(void);
|
||||
void rqSetMem8(void);
|
||||
void rqGetMem8(void);
|
||||
|
||||
#endif // REQUEST_HANDLERS_H
|
||||
|
|
Loading…
Reference in a new issue