Skip to content

Commit

Permalink
Cascoda SDK patch release v0.23-5
Browse files Browse the repository at this point in the history
Make battery monitoring dynamic, removing a devboard config option
Update documentation
KNX-IoT port bugfixes
  • Loading branch information
tiniuclx committed May 22, 2023
1 parent 60538f6 commit 7a7da3b
Show file tree
Hide file tree
Showing 23 changed files with 751 additions and 85 deletions.
8 changes: 8 additions & 0 deletions baremetal/cascoda-bm-devboard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ add_executable(devboard-gfx-1-54
target_link_libraries(devboard-gfx-1-54 cascoda-bm test15-4-api cascoda-bm-devboard mikrosdk-click sensorif eink-driver-1-54-half-res)
cascoda_make_binary(devboard-gfx-1-54 CASCODA_BUILD_BINARIES)
cascoda_put_subdir(devboard devboard-gfx-1-54)

add_executable(devboard-click-batt
${PROJECT_SOURCE_DIR}/examples/devboard_app_click_batt.c
)

target_link_libraries(devboard-click-batt cascoda-bm cascoda-bm-devboard mikrosdk-click)
cascoda_make_binary(devboard-click-batt CASCODA_BUILD_BINARIES)
cascoda_put_subdir(devboard devboard-click-batt)
5 changes: 1 addition & 4 deletions baremetal/cascoda-bm-devboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ This module contains example applications to demonstrate the use of the APIs for
| devboard-gfx-x-x | `examples/devboard_app_gfx_x_x.c` | Example app demonstrating how the devboard can show graphics (menu) on an eink display (where x-x is replaced by the size, e.g. 2-9 meaning 2.9 inches). |
| devboard-sleep | `examples/devboard_app_sleep.c` | Example app demonstrating the sleep modes. |
| devboard-batt | `examples/devboard_app_batt.c` | Example app demonstrating the battery monitoring functions. |
| devboard-click-batt | `examples/devboard_app_click_batt.c` | Example app demonstrating combined use of peripherals and battery monitoring. |
## Building instructions

Assuming that you have already [set up your build directories](../../README.md#building), in order to get the devboard example binaries to build, you need to change the CMake configuration as follows:

```CMake
CASCODA_CHILI2_CONFIG_STRING:STRING=DEV_BOARD
```
When using the Battry monitoring functions on the Development Board, the following configuration should be used:
```CMake
CASCODA_CHILI2_CONFIG_STRING:STRING=DEV_BOARD_BATT
```
The recommended method of doing this is [using the tools that come with CMake](https://cmake.org/runningcmake/). However, if you know what you are doing, then you can alternatively edit the `CMakeCache.txt` file yourself to make those changes.

After building, the example binaries will be found in `bin/devboard/` in your build directory.
61 changes: 52 additions & 9 deletions baremetal/cascoda-bm-devboard/examples/devboard_app_batt.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "devboard_batt.h"
#include "devboard_btn.h"

#define GET_CHARGE_STAT 1
#define GET_VOLTS 1
#define GET_USB_PRESENT 1

/* reporting period in [ms] */
#define REPORT_TIME 5000

Expand All @@ -42,22 +46,42 @@ static ca_error ReportBattStatus(void *aContext)
u8_t charging = 0;
u8_t vbusconnected = 0;

charging = DVBD_BattGetChargingStatus();
vbatt = DVBD_BattGetVoltage();
vbusconnected = DVBD_BattGetVbusConnected();
if (GET_CHARGE_STAT)
charging = DVBD_BattGetChargeStat();
if (GET_VOLTS)
vbatt = DVBD_BattGetVolts();
if (GET_USB_PRESENT)
vbusconnected = DVBD_BattGetUSBPresent();

printf("%4us BattStatus: ", (TIME_ReadAbsoluteTime() / 1000));
printf("Vbatt: %2d.%02u V;", (vbatt / 100), abs(vbatt % 100));
printf(" %s;", ((charging == CHARGING) ? "charging" : "not charging"));
printf(" %s;", ((vbusconnected == CONNECTED) ? "+5V connected" : "+5V not connected"));
if (GET_VOLTS)
printf("Vbatt: %2d.%02u V;", (vbatt / 100), abs(vbatt % 100));
if (GET_CHARGE_STAT)
printf(" %s;", ((charging == CHARGING) ? "charging" : "not charging"));
if (GET_USB_PRESENT)
printf(" %s;", ((vbusconnected == CONNECTED) ? "+5V connected" : "+5V not connected"));
printf("\n");

TASKLET_ScheduleDelta(&g_report_batt_tasklet, REPORT_TIME, NULL);

if (vbusconnected)
DVBD_SetLED(LED_BTN_1, LED_ON);
else
DVBD_SetLED(LED_BTN_1, LED_OFF);

if (charging)
DVBD_SetLED(LED_BTN_2, LED_ON);
else
DVBD_SetLED(LED_BTN_2, LED_OFF);

#if defined(USE_USB)
if (vbusconnected)
g_go_sleep = 0;
else
g_go_sleep = 1;
#else
g_go_sleep = 1;
#endif // USE_USB

return CA_ERROR_SUCCESS;
}
Expand All @@ -76,9 +100,28 @@ static void hardware_init(void)
printf("Failed to register SW4\n");

DVBD_SetLED(LED_BTN_0, LED_ON);
DVBD_SetLED(LED_BTN_1, LED_ON);
DVBD_SetLED(LED_BTN_2, LED_ON);
DVBD_SetLED(LED_BTN_3, LED_ON);
DVBD_SetLED(LED_BTN_1, LED_OFF);
DVBD_SetLED(LED_BTN_2, LED_OFF);
DVBD_SetLED(LED_BTN_3, LED_OFF);

if (GET_CHARGE_STAT)
{
/* initialise CHARGE_STAT */
if (DVBD_BattInitChargeStat())
printf("Failed to initialise CHARGE_STAT\n");
}
if (GET_VOLTS)
{
/* initialise VOLTS and VOLTS_TEST */
if (DVBD_BattInitVolts())
printf("Failed to initialise VOLTS/VOLTS_TEST\n");
}
if (GET_USB_PRESENT)
{
/* initialise USB_PRESENT */
if (DVBD_BattInitUSBPresent())
printf("Failed to initialise USB_PRESENT\n");
}

TASKLET_Init(&g_report_batt_tasklet, &ReportBattStatus);
TASKLET_ScheduleDelta(&g_report_batt_tasklet, REPORT_TIME, NULL);
Expand Down
Loading

0 comments on commit 7a7da3b

Please sign in to comment.