From 71ae40c260da98ab004bbeea6ac490344f853c67 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Thu, 24 Dec 2020 16:52:07 +0100 Subject: [PATCH] code for bitmasks sanitzed --- include/globals.h | 35 +++++++++++++++++++---------------- include/irqhandler.h | 20 ++++++++++---------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/include/globals.h b/include/globals.h index fecfbf32..c8755412 100644 --- a/include/globals.h +++ b/include/globals.h @@ -18,25 +18,28 @@ #include "mallocator.h" #include +#define _bit(b) (1U << (b)) +#define _bitl(b) (1UL << (b)) + // bits in payloadmask for filtering payload data -#define COUNT_DATA (0x01) -#define ALARM_DATA (0x02) -#define MEMS_DATA (0x04) -#define GPS_DATA (0x08) -#define SENSOR1_DATA (0x10) -#define SENSOR2_DATA (0x20) -#define SENSOR3_DATA (0x40) -#define BATT_DATA (0x80) +#define COUNT_DATA _bit(1) +#define ALARM_DATA _bit(2) +#define MEMS_DATA _bit(3) +#define GPS_DATA _bit(4) +#define SENSOR1_DATA _bit(5) +#define SENSOR2_DATA _bit(6) +#define SENSOR3_DATA _bit(7) +#define BATT_DATA _bit(8) // bits in configmask for device runmode control -#define GPS_MODE (0x01) -#define ALARM_MODE (0x02) -#define BEACON_MODE (0x04) -#define UPDATE_MODE (0x08) -#define FILTER_MODE (0x10) -#define ANTENNA_MODE (0x20) -#define BLE_MODE (0x40) -#define SCREEN_MODE (0x80) +#define GPS_MODE _bit(1) +#define ALARM_MODE _bit(2) +#define BEACON_MODE _bit(3) +#define UPDATE_MODE _bit(4) +#define FILTER_MODE _bit(5) +#define ANTENNA_MODE _bit(6) +#define BLE_MODE _bit(7) +#define SCREEN_MODE _bit(8) // length of display buffer for lmic event messages #define LMIC_EVENTMSG_LEN 17 diff --git a/include/irqhandler.h b/include/irqhandler.h index 958acc4e..9e52ccbf 100644 --- a/include/irqhandler.h +++ b/include/irqhandler.h @@ -1,16 +1,16 @@ #ifndef _IRQHANDLER_H #define _IRQHANDLER_H -#define DISPLAY_IRQ 0x001 -#define BUTTON_IRQ 0x002 -#define SENDCYCLE_IRQ 0x004 -#define CYCLIC_IRQ 0x008 -#define TIMESYNC_IRQ 0x010 -#define MASK_IRQ 0x020 -#define UNMASK_IRQ 0x040 -#define BME_IRQ 0x080 -#define MATRIX_DISPLAY_IRQ 0x100 -#define PMU_IRQ 0x200 +#define DISPLAY_IRQ _bitl(1) +#define BUTTON_IRQ _bitl(2) +#define SENDCYCLE_IRQ _bitl(3) +#define CYCLIC_IRQ _bitl(4) +#define TIMESYNC_IRQ _bitl(5) +#define MASK_IRQ _bitl(6) +#define UNMASK_IRQ _bitl(7) +#define BME_IRQ _bitl(8) +#define MATRIX_DISPLAY_IRQ _bitl(9) +#define PMU_IRQ _bitl(10) #include "globals.h" #include "button.h"