|
@@ -116,7 +116,7 @@ static btn_hndlr bha[Button_Num] = {btn1_handler, btn2_handler, btn3_handler, bt
|
|
/*
|
|
/*
|
|
* INA process thread.
|
|
* INA process thread.
|
|
*/
|
|
*/
|
|
-static THD_WORKING_AREA(waInaThread, 128);
|
|
|
|
|
|
+static THD_WORKING_AREA(waInaThread, 256);
|
|
static THD_FUNCTION(InaThread, arg) {
|
|
static THD_FUNCTION(InaThread, arg) {
|
|
(void)arg;
|
|
(void)arg;
|
|
|
|
|
|
@@ -129,7 +129,7 @@ static THD_FUNCTION(InaThread, arg) {
|
|
/*
|
|
/*
|
|
* Charger process thread. Once per second.
|
|
* Charger process thread. Once per second.
|
|
*/
|
|
*/
|
|
-static THD_WORKING_AREA(waChrgThread, 128);
|
|
|
|
|
|
+static THD_WORKING_AREA(waChrgThread, 256);
|
|
static THD_FUNCTION(ChrgThread, arg) {
|
|
static THD_FUNCTION(ChrgThread, arg) {
|
|
(void)arg;
|
|
(void)arg;
|
|
|
|
|
|
@@ -169,9 +169,7 @@ static THD_FUNCTION(ChrgThread, arg) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/* Show new timer value */
|
|
/* Show new timer value */
|
|
- chSysLockFromISR();
|
|
|
|
- chEvtBroadcastI(&time_event);
|
|
|
|
- chSysUnlockFromISR();
|
|
|
|
|
|
+ chEvtBroadcast(&time_event);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -306,41 +304,41 @@ int main(void) {
|
|
events = chEvtWaitAny(ALL_EVENTS);
|
|
events = chEvtWaitAny(ALL_EVENTS);
|
|
|
|
|
|
if (events & INA_ALL_VALUSE) {
|
|
if (events & INA_ALL_VALUSE) {
|
|
- /* need to control curren/voltage in charge/decharge modes */
|
|
|
|
|
|
+ /* place to control curren/voltage in charge/decharge modes */
|
|
|
|
|
|
tmp1 = Voltage / 1000;
|
|
tmp1 = Voltage / 1000;
|
|
tmp2 = Voltage % 1000;
|
|
tmp2 = Voltage % 1000;
|
|
- chsnprintf(buf, 11, "V:%2d.%03uV", tmp1, tmp2);
|
|
|
|
- gdispFillStringBox(1, 123, 106, 29, buf, font2, Red, Gray, gJustifyCenter);
|
|
|
|
|
|
+ chsnprintf(buf, 11, "U:%2d.%03uV", tmp1, tmp2);
|
|
|
|
+ gdispFillStringBox(1, 123, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
|
|
|
|
tmp1 = Current / 1000;
|
|
tmp1 = Current / 1000;
|
|
tmp2 = Current % 1000;
|
|
tmp2 = Current % 1000;
|
|
chsnprintf(buf, 11, "I:%2d.%03uA", tmp1, tmp2);
|
|
chsnprintf(buf, 11, "I:%2d.%03uA", tmp1, tmp2);
|
|
- gdispFillStringBox(1, 153, 106, 29, buf, font2, Red, Gray, gJustifyCenter);
|
|
|
|
|
|
+ gdispFillStringBox(1, 153, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
|
|
|
|
tmp1 = Power / 1000;
|
|
tmp1 = Power / 1000;
|
|
tmp2 = Power % 1000;
|
|
tmp2 = Power % 1000;
|
|
chsnprintf(buf, 11, "P:%2d.%03uW", tmp1, tmp2);
|
|
chsnprintf(buf, 11, "P:%2d.%03uW", tmp1, tmp2);
|
|
- gdispFillStringBox(1, 183, 106, 29, buf, font2, Red, Gray, gJustifyCenter);
|
|
|
|
|
|
+ gdispFillStringBox(1, 183, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
|
|
|
|
tmp0 = (Capacity_I + 1800) / 3600;
|
|
tmp0 = (Capacity_I + 1800) / 3600;
|
|
tmp1 = tmp0 / 1000;
|
|
tmp1 = tmp0 / 1000;
|
|
tmp2 = tmp0 % 1000;
|
|
tmp2 = tmp0 % 1000;
|
|
chsnprintf(buf, 13, "CI:%2d.%03uAh", tmp1, tmp2);
|
|
chsnprintf(buf, 13, "CI:%2d.%03uAh", tmp1, tmp2);
|
|
- gdispFillStringBox(160, 153, 106, 29, buf, font2, Red, Gray, gJustifyCenter);
|
|
|
|
|
|
+ gdispFillStringBox(160, 153, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
|
|
|
|
tmp0 = (Capacity_P + 1800) / 3600;
|
|
tmp0 = (Capacity_P + 1800) / 3600;
|
|
tmp1 = tmp0 / 1000;
|
|
tmp1 = tmp0 / 1000;
|
|
tmp2 = tmp0 % 1000;
|
|
tmp2 = tmp0 % 1000;
|
|
chsnprintf(buf, 13, "CP:%2d.%03uWh", tmp1, tmp2);
|
|
chsnprintf(buf, 13, "CP:%2d.%03uWh", tmp1, tmp2);
|
|
- gdispFillStringBox(160, 183, 106, 29, buf, font2, Red, Gray, gJustifyCenter);
|
|
|
|
|
|
+ gdispFillStringBox(160, 183, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
}
|
|
}
|
|
|
|
|
|
if (events & INA_BUS_VALUES) {
|
|
if (events & INA_BUS_VALUES) {
|
|
tmp1 = Voltage / 1000;
|
|
tmp1 = Voltage / 1000;
|
|
tmp2 = Voltage % 1000;
|
|
tmp2 = Voltage % 1000;
|
|
- chsnprintf(buf, 11, "V:%2d.%03uV", tmp1, tmp2);
|
|
|
|
- gdispFillStringBox(1, 123, 106, 29, buf, font2, Red, Gray, gJustifyCenter);
|
|
|
|
|
|
+ chsnprintf(buf, 11, "U:%2d.%03uV", tmp1, tmp2);
|
|
|
|
+ gdispFillStringBox(1, 123, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
}
|
|
}
|
|
|
|
|
|
if (events & CHRGR_ST_CHANGE) {
|
|
if (events & CHRGR_ST_CHANGE) {
|
|
@@ -439,7 +437,7 @@ int main(void) {
|
|
} else {
|
|
} else {
|
|
chsnprintf(buf, 12, "T:00:00:00");
|
|
chsnprintf(buf, 12, "T:00:00:00");
|
|
}
|
|
}
|
|
- gdispFillStringBox(160, 123, 158, 29, buf, font2, Red, Gray, gJustifyCenter);
|
|
|
|
|
|
+ gdispFillStringBox(160, 123, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -470,7 +468,7 @@ static void prepare_Screen(void) {
|
|
// gdispDrawStringBox(1, 106, 78, 15, " ", font1, Yellow, gJustifyLeft);
|
|
// gdispDrawStringBox(1, 106, 78, 15, " ", font1, Yellow, gJustifyLeft);
|
|
|
|
|
|
/* clear bootom area */
|
|
/* clear bootom area */
|
|
- gdispFillStringBox(1, 123, 318, 115, " ", font2, Red, Gray, gJustifyCenter);
|
|
|
|
|
|
+ gdispFillStringBox(1, 123, 318, 115, " ", font2, Red, Gray, gJustifyLeft);
|
|
|
|
|
|
/* create the console window */
|
|
/* create the console window */
|
|
{
|
|
{
|
|
@@ -535,10 +533,8 @@ static void btn2_handler(button_state_t state) {
|
|
Capacity_P = ch_Capacity_P;
|
|
Capacity_P = ch_Capacity_P;
|
|
Timer = chTimer;
|
|
Timer = chTimer;
|
|
|
|
|
|
- chSysLockFromISR();
|
|
|
|
- chEvtBroadcastI(&ina_all_event);
|
|
|
|
- chEvtBroadcastI(&time_event);
|
|
|
|
- chSysUnlockFromISR();
|
|
|
|
|
|
+ chEvtBroadcast(&ina_all_event);
|
|
|
|
+ chEvtBroadcast(&time_event);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -549,10 +545,8 @@ static void btn3_handler(button_state_t state) {
|
|
Capacity_P = dech_Capacity_P;
|
|
Capacity_P = dech_Capacity_P;
|
|
Timer = dechTimer;
|
|
Timer = dechTimer;
|
|
|
|
|
|
- chSysLockFromISR();
|
|
|
|
- chEvtBroadcastI(&ina_all_event);
|
|
|
|
- chEvtBroadcastI(&time_event);
|
|
|
|
- chSysUnlockFromISR();
|
|
|
|
|
|
+ chEvtBroadcast(&ina_all_event);
|
|
|
|
+ chEvtBroadcast(&time_event);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -577,9 +571,7 @@ static void btn4_handler(button_state_t state) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- chSysLockFromISR();
|
|
|
|
- chEvtBroadcastI(&chrgr_st_event);
|
|
|
|
- chSysUnlockFromISR();
|
|
|
|
|
|
+ chEvtBroadcast(&chrgr_st_event);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -628,20 +620,14 @@ static void ina_Process(void) {
|
|
Capacity_I += Current;
|
|
Capacity_I += Current;
|
|
Capacity_P += Power;
|
|
Capacity_P += Power;
|
|
|
|
|
|
- chSysLockFromISR();
|
|
|
|
- chEvtBroadcastI(&ina_all_event);
|
|
|
|
- chSysUnlockFromISR();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ chEvtBroadcast(&ina_all_event);
|
|
|
|
+ } else {
|
|
/* Show bus voltage in STOP mode */
|
|
/* Show bus voltage in STOP mode */
|
|
- if (charger_State == Stop) {
|
|
|
|
Voltage = sumVoltage;
|
|
Voltage = sumVoltage;
|
|
sumCurrent=0;
|
|
sumCurrent=0;
|
|
sumVoltage=0;
|
|
sumVoltage=0;
|
|
|
|
|
|
- chSysLockFromISR();
|
|
|
|
- chEvtBroadcastI(&ina_bus_event);
|
|
|
|
- chSysUnlockFromISR();
|
|
|
|
|
|
+ chEvtBroadcast(&ina_bus_event);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|