Skip to content

Commit

Permalink
Add energy level debugging procedure #6
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoeiterer committed Aug 4, 2017
1 parent 9033b45 commit ee63da3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions firmware/I2C.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "I2C.h"
#include "misc.h"

volatile uint8_t EPS_data[71] = {0x7E, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 0, 0, 69, 70};
volatile uint8_t EPS_data[71] = {0x7E, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 0, 0x01, 69, 70};
volatile uint8_t EPS_data2[71] = {0};

void I2C_tx(uint8_t tx_data){
Expand Down Expand Up @@ -35,7 +35,7 @@ __interrupt void USCI_B2_ISR(void)
case 6: // Vector 6: STTIFG
UCB2IFG &= ~UCSTTIFG; // Clear start condition int flag
memcpy(EPS_data2, EPS_data, 71);
EPS_data2[70] = crc8(0x03, 0x92, EPS_data2+1, 69);
EPS_data2[CRC] = crc8(0x03, 0x92, EPS_data2+1, 69);
break;
case 8: // Vector 8: STPIFG
UCB2IFG &= ~UCSTPIFG; // Clear stop condition int flag
Expand Down
1 change: 1 addition & 0 deletions firmware/I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <stdint.h>
#include "crc.h"
#include "hal.h"

void I2C_config(void);

Expand Down
10 changes: 5 additions & 5 deletions firmware/energy_level_algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
#include "hal.h"

#define maxChargeLevel 0x1300
#define level1 0x10
#define level2 0x20
#define level3 0x30
#define level4 0x40
#define level5 0x50
#define level1 0x01
#define level2 0x02
#define level3 0x03
#define level4 0x04
#define level5 0x05

uint8_t energyLevelAlgorithm(uint8_t previous_level, uint16_t chargeLevel);

Expand Down
9 changes: 8 additions & 1 deletion firmware/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,18 @@ __interrupt void timer0_a0_isr(void){

watchdog_reset_counter();

#ifdef _DEBUG
uint8_t string[5];
sprintf(string, "%#04x", EPS_data[eps_status]);
uart_tx_debug("Energy Level: ");
uart_tx_debug(string);
uart_tx_debug("\r\n");
#endif

if(counter_30s == 9){
volatile uint8_t beacon_packet[33] = {0};
counter_30s = 0;


beacon_packet[0] = 0x7E;
beacon_packet[1] = EPS_data[battery1_voltage_LSB];
beacon_packet[2] = EPS_data[battery1_voltage_MSB];
Expand Down

0 comments on commit ee63da3

Please sign in to comment.