cofnig stuff

This commit is contained in:
2019-10-16 12:04:59 +02:00
parent b0257f5888
commit 0a39c5c85c
5 changed files with 64 additions and 14 deletions

View File

@ -3,6 +3,7 @@
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include <libconfig.h>
#include "LS7366R.h"
#include "influx.h"
@ -13,6 +14,8 @@ const int INTR_IN = 19;
const int SPI_CHAN = 0;
const int SPI_SPEED = 1000000;
config_t cfg;
void isr() {
static uint32_t lastCounter = 0;
@ -36,6 +39,16 @@ void init() {
pinMode(INTR_IN, INPUT);
}
void readConfig() {
config_init(&cfg);
if (! config_read_file(&cfg, "/opt/etc/counter.cfg")) {
fprintf(stderr, "failed to read config file: %s:%d - %s\n",
config_error_file(&cfg), config_error_line(&cfg),
config_error_text(&cfg));
config_destroy(&cfg);
exit(-1);
}
}
void start() {
wiringPiISR(INTR_IN, INT_EDGE_RISING, isr);
}
@ -43,7 +56,7 @@ void start() {
int main (void) {
init();
ls7366rInit(SPI_CHAN);
influxInit();
influxInit(&cfg);
start();
@ -54,4 +67,7 @@ int main (void) {
// printf("%f\n", f);
influxAddFrequency(f);
}
// will never be reached
config_destroy(&cfg);
}