Skip to content

Commit

Permalink
Fix silly voltage bitsetting.
Browse files Browse the repository at this point in the history
  • Loading branch information
linguini1 committed Jun 7, 2024
1 parent 4ca08bb commit 95534fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
12 changes: 3 additions & 9 deletions src/collectors/pac195x_clctr.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
/** The RSENSE value connected to the PAC1952-2 in milliohms. */
#define RSENSE 18

typedef struct {
uint8_t type;
uint8_t id;
int16_t voltage;
} voltage_msg_t;

void *pac1952_2_collector(void *args) {

/* Open message queue. */
Expand Down Expand Up @@ -48,7 +42,7 @@ void *pac1952_2_collector(void *args) {
}

uint16_t vbus[2];
voltage_msg_t msg;
common_t msg;

for (;;) {

Expand All @@ -63,15 +57,15 @@ void *pac1952_2_collector(void *args) {
// Calculate voltage on SENSE 1
msg.type = TAG_VOLTAGE;
msg.id = 1;
msg.voltage = pac195x_calc_bus_voltage(32, vbus[0], false);
msg.data.U32 = pac195x_calc_bus_voltage(32, vbus[0], false);
if (mq_send(sensor_q, (char *)&msg, sizeof(msg), 0) == -1) {
fprintf(stderr, "Could not send voltage measurement: %s\n", strerror(errno));
}

// Calculate voltage on SENSE 2
msg.type = TAG_VOLTAGE;
msg.id = 2;
msg.voltage = pac195x_calc_bus_voltage(32, vbus[1], false);
msg.data.U32 = pac195x_calc_bus_voltage(32, vbus[1], false);
if (mq_send(sensor_q, (char *)&msg, sizeof(msg), 0) == -1) {
fprintf(stderr, "Could not send voltage measurement: %s\n", strerror(errno));
}
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/sensor_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ inline errno_t __attribute__((always_inline)) sensor_open(Sensor sensor) { retur
* @param nbytes Will be populated with the number of bytes that were stored in buf after the read.
* @return Error status of setting up the sensor. EOK if successful.
*/
inline errno_t __attribute__((always_inline)) sensor_read(Sensor sensor, const SensorTag tag, void *buf,
size_t *nbytes) {
inline errno_t __attribute__((always_inline))
sensor_read(Sensor sensor, const SensorTag tag, void *buf, size_t *nbytes) {
return sensor.read(&sensor, tag, buf, nbytes);
}

Expand Down

0 comments on commit 95534fb

Please sign in to comment.