cofnig stuff
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user