Last active
December 12, 2017 17:20
-
-
Save msloth/55f2d84556bf55f1debcb0678c62c6e6 to your computer and use it in GitHub Desktop.
The client file for the Thingsquare firmware SDK used for the demo binaries.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "thsq.h" | |
#include "ti-lib.h" | |
#include "gpio-interrupt.h" | |
#include "lib/sensors.h" | |
#include "batmon-sensor.h" | |
#include "dev/leds-arch.h" | |
#include "dev/cc26xx-uart.h" | |
/*---------------------------------------------------------------------------*/ | |
void | |
init_leds(void) | |
{ | |
leds_arch_set_pins(IOID_6, IOID_7, IOID_UNUSED); | |
} | |
/*---------------------------------------------------------------------------*/ | |
void | |
init_uart(void) | |
{ | |
cc26xx_uart_init(IOID_3, IOID_2, IOID_UNUSED, IOID_UNUSED); | |
} | |
/*---------------------------------------------------------------------------*/ | |
static void | |
callback_thsq(enum thsq_reason r, const char *msg, int len) | |
{ | |
if(r == THSQ_PERIOD) { | |
int value; | |
value = batmon_sensor.value(BATMON_SENSOR_TYPE_VOLT); | |
thsq_sset_printf("b", "%d.%03d", value / 1000, value % 1000); | |
thsq_sset("t", batmon_sensor.value(BATMON_SENSOR_TYPE_TEMP)); | |
thsq_push(); | |
} | |
} | |
/*---------------------------------------------------------------------------*/ | |
void | |
app(void) | |
{ | |
/* Initialize the lighting module */ | |
thsq_lighting_init(); | |
thsq_lighting_set_lamp(); | |
/* Initialize the configurable GPIO module */ | |
thsq_gpio_init(); | |
/* Make the GPIO module listen to events from the lighting module. */ | |
thsq_gpio_attach_lighting(); | |
/* Configure GPIO module PWMs, called from lighting module. We set | |
the PWM to run on the RED LED, which is on the IOID_6 pin. */ | |
thsq_pwm_cc26xx_cc13xx_conf(thsq_gpio_get_pwm_red(), IOID_6, | |
5000UL, GPT0_BASE, 0); | |
/* Restore lighting settings from before last reboot. This must be | |
called after attaching the GPIO module to the lighting module to | |
make the lighting settings be transported to the GPIO module. */ | |
thsq_lighting_apply_last(); | |
/* Initialize the serial input/output module */ | |
thsq_serialline_init(); | |
/* Setup the periodic callback for the temperature sensor */ | |
static struct thsq_callback cb; | |
thsq_add_callback(&cb, callback_thsq); | |
SENSORS_ACTIVATE(batmon_sensor); | |
/* Allow the device to be used as a packet sniffer */ | |
thsq_sniffer_init(); | |
} | |
/*---------------------------------------------------------------------------*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment