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
|
@ -70,6 +70,14 @@ void handleRequest()
|
|||
case RQ_PWM_SET_VALUE:
|
||||
rqPwmSetValue();
|
||||
break;
|
||||
|
||||
case RQ_SET_REG:
|
||||
rqSetRegister();
|
||||
break;
|
||||
|
||||
case RQ_GET_REG:
|
||||
rqGetRegister();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -244,3 +252,24 @@ void rqPwmSetValue()
|
|||
usart.writeByte(USART::MSG_OK);
|
||||
usart.flush();
|
||||
}
|
||||
|
||||
void rqSetRegister()
|
||||
{
|
||||
usart.initTX();
|
||||
uint16_t reg = usart.readByte();
|
||||
uint16_t val = usart.readByte();
|
||||
|
||||
(*(volatile uint8_t *) reg) = val;
|
||||
usart.writeByte((*(volatile uint8_t *) reg));
|
||||
usart.flush();
|
||||
}
|
||||
|
||||
void rqGetRegister()
|
||||
{
|
||||
usart.initTX();
|
||||
uint16_t reg = usart.readByte();
|
||||
|
||||
usart.writeByte((*(volatile uint8_t *) reg));
|
||||
usart.flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,11 @@ constexpr static uint8_t RQ_DSW = 9;
|
|||
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;
|
||||
|
||||
uint8_t const rq_len[] = {
|
||||
/* RQ_DISC */ 1,
|
||||
|
@ -40,7 +42,9 @@ uint8_t const rq_len[] = {
|
|||
/* RQ_ADC */ 2,
|
||||
/* RQ_ADC_DAC_STROKE */ 9,
|
||||
/* RQ_PWM_SET_FREQ */ 5,
|
||||
/* RQ_PWM_SET_VALUE */ 2
|
||||
/* RQ_PWM_SET_VALUE */ 2,
|
||||
/* RQ_SET_REG */ 3,
|
||||
/* RQ_GET_REG */ 2
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -65,5 +69,7 @@ void rqAnalogRead(void);
|
|||
void rqAdcDacStroke(void);
|
||||
void rqPwmSetFreq(void);
|
||||
void rqPwmSetValue(void);
|
||||
void rqSetRegister(void);
|
||||
void rqGetRegister(void);
|
||||
|
||||
#endif // REQUESTS_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue