new commands implemented
This commit is contained in:
@@ -15,6 +15,7 @@ typedef enum {
|
|||||||
com_getMonthDay,
|
com_getMonthDay,
|
||||||
com_getYear,
|
com_getYear,
|
||||||
com_getTimeZone,
|
com_getTimeZone,
|
||||||
|
com_getDate,
|
||||||
|
|
||||||
com_setTime,
|
com_setTime,
|
||||||
com_setMonthDay,
|
com_setMonthDay,
|
||||||
@@ -26,6 +27,7 @@ typedef enum {
|
|||||||
com_setColour_background,
|
com_setColour_background,
|
||||||
|
|
||||||
com_setTimeZone,
|
com_setTimeZone,
|
||||||
|
com_setDate,
|
||||||
|
|
||||||
com_readNV,
|
com_readNV,
|
||||||
com_writeNV,
|
com_writeNV,
|
||||||
@@ -49,6 +51,7 @@ void cmd_GetTime(uint32_t time);
|
|||||||
void cmd_GetMonthDay(uint32_t d);
|
void cmd_GetMonthDay(uint32_t d);
|
||||||
void cmd_GetYear(uint32_t d);
|
void cmd_GetYear(uint32_t d);
|
||||||
void cmd_GetTimeZone(uint32_t d);
|
void cmd_GetTimeZone(uint32_t d);
|
||||||
|
void cmd_GetDate(uint32_t d);
|
||||||
|
|
||||||
void cmd_SetTime(uint32_t time);
|
void cmd_SetTime(uint32_t time);
|
||||||
void cmd_SetYear(uint32_t year);
|
void cmd_SetYear(uint32_t year);
|
||||||
@@ -59,6 +62,8 @@ void cmd_setColour_minute(uint32_t colour);
|
|||||||
void cmd_setColour_second(uint32_t colour);
|
void cmd_setColour_second(uint32_t colour);
|
||||||
void cmd_setColour_background(uint32_t colour);
|
void cmd_setColour_background(uint32_t colour);
|
||||||
|
|
||||||
|
void cmd_SetDate(uint32_t d);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* INC_MYCOMMS_H_ */
|
#endif /* INC_MYCOMMS_H_ */
|
||||||
|
|||||||
@@ -48,47 +48,114 @@ void (*commands[])(uint32_t) = {
|
|||||||
cmd_GetMonthDay, // 2
|
cmd_GetMonthDay, // 2
|
||||||
cmd_GetYear, // 3
|
cmd_GetYear, // 3
|
||||||
cmd_GetTimeZone, // 4
|
cmd_GetTimeZone, // 4
|
||||||
|
cmd_GetDate, // 5
|
||||||
|
|
||||||
cmd_SetTime, // 5
|
cmd_SetTime, // 6
|
||||||
cmd_SetMonthDay, // 6
|
cmd_SetMonthDay, // 7
|
||||||
cmd_SetYear, // 7
|
cmd_SetYear, // 8
|
||||||
|
|
||||||
cmd_setColour_hour, // 8
|
cmd_setColour_hour, // 9
|
||||||
cmd_setColour_minute, // 9
|
cmd_setColour_minute, // 10
|
||||||
cmd_setColour_second, // 10
|
cmd_setColour_second, // 11
|
||||||
cmd_setColour_background, // 11
|
cmd_setColour_background, // 12
|
||||||
|
|
||||||
cmd_Set_TimeZone, // 12
|
cmd_Set_TimeZone, // 13
|
||||||
|
cmd_SetDate, // 14
|
||||||
|
|
||||||
cmd_readNV, // 13
|
cmd_readNV, // 15
|
||||||
cmd_writeNV, // 14
|
cmd_writeNV, // 16
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void cmd_GetTimeZone(uint32_t d){
|
void cmd_GetTimeZone(uint32_t d){
|
||||||
|
uint8_t respBuf[4] = {0};
|
||||||
|
|
||||||
|
int8_t z = ds1307_get_time_zone_hour();
|
||||||
|
|
||||||
|
|
||||||
|
respBuf[0] = 200 + com_getYear;
|
||||||
|
if(z<0){
|
||||||
|
respBuf[1] = 1;
|
||||||
|
}
|
||||||
|
respBuf[2] = abs(z);
|
||||||
|
|
||||||
|
CDC_Transmit_FS(respBuf, sizeof(respBuf));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_GetYear(uint32_t d){
|
void cmd_GetYear(uint32_t d){
|
||||||
|
|
||||||
|
uint8_t respBuf[4] = {0};
|
||||||
|
|
||||||
|
respBuf[0] = 200 + com_getYear;
|
||||||
|
uint16_t y = ds1307_get_year();
|
||||||
|
|
||||||
|
respBuf[1] = y/100;
|
||||||
|
respBuf[2] = (uint8_t) y & 0xFF;
|
||||||
|
|
||||||
|
CDC_Transmit_FS(respBuf, sizeof(respBuf));
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_GetDate(uint32_t d){
|
||||||
|
uint8_t respBuf[4] = {0};
|
||||||
|
|
||||||
|
respBuf[0] = 200 + com_getDate;
|
||||||
|
respBuf[1] = ds1307_get_date();
|
||||||
|
respBuf[2] = ds1307_get_month();
|
||||||
|
respBuf[3] = ds1307_get_year();
|
||||||
|
|
||||||
|
CDC_Transmit_FS(respBuf, sizeof(respBuf));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_GetMonthDay(uint32_t d){
|
void cmd_GetMonthDay(uint32_t d){
|
||||||
|
|
||||||
|
uint8_t respBuf[4] = {0};
|
||||||
|
|
||||||
|
respBuf[0] = 200 + com_getMonthDay;
|
||||||
|
respBuf[1] = ds1307_get_date();
|
||||||
|
respBuf[2] = ds1307_get_month();
|
||||||
|
respBuf[3] = 0;
|
||||||
|
|
||||||
|
CDC_Transmit_FS(respBuf, sizeof(respBuf));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Format: d:m:yy
|
||||||
|
*/
|
||||||
|
void cmd_SetDate(uint32_t d){
|
||||||
|
|
||||||
|
ds1307_set_day(UART_RxBuf[1]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_SetYear(uint32_t year){
|
void cmd_SetYear(uint32_t year){
|
||||||
|
|
||||||
|
uint16_t y = (uint16_t)(UART_RxBuf[1] *100) + UART_RxBuf[2];
|
||||||
|
|
||||||
|
ds1307_set_year(y);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_SetMonthDay(uint32_t){
|
void cmd_SetMonthDay(uint32_t){
|
||||||
|
|
||||||
|
ds1307_set_day(UART_RxBuf[1]);
|
||||||
|
ds1307_set_month(UART_RxBuf[2]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_Set_TimeZone(uint32_t){
|
void cmd_Set_TimeZone(uint32_t){
|
||||||
|
int z = 0;
|
||||||
|
|
||||||
|
z = abs(UART_RxBuf[2]);
|
||||||
|
if(UART_RxBuf[1] == 1){
|
||||||
|
z = z * -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ds1307_set_time_zone(z, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_readNV(uint32_t data){
|
static void cmd_readNV(uint32_t data){
|
||||||
|
|||||||
Reference in New Issue
Block a user