| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- // globals definition
- //------------------------
- // Configuration section
- // How many slots do we currently support?
- // use 1 for debugging, 4 for production
- #define NUM_SLOTS 4
- //Battery Tolerance
- // how much tolerance do we allow if we charge / discharge before we
- // trigger the control loop to adjust the value
- #define BATTERY_CURRENT_THRESHOLD 5
- // Mainloop sleep time
- // Time to sleep between two mainloop intervals
- // We have a 32 MHz clock
- // debugging e.g. 32000000*5 -> 5s
- // production e.g. 320000 (10ms) (Validate that this is really the case!)
- // should be large for debugging, (e.g. )
- // small for production
- #define MAINLOOP_DELAY (3200)
- // i2c address for acting as target
- // (based on the GPIO 1 integer is added)
- #define I2C_TARGET_BASE_ADDRESS 0x48
- // PWM Initalization delay
- // in order to ensure they don't go in exactly the same frequency to
- // avoid EMV peaks
- #define PWM_INITIALIZATION_DELAY 100
- // PWM Define max CC period
- #define MAX_PWM_CYCLE 320
- //------------
- // Section for configuring debugging outputs
- //------------
- // printf ADC outputs
- #define DEBUG_ADC 1
- // printf DAC outputs
- #define DEBUG_DAC 1
- // printf control loop outputs
- #define DEBUG_CTRL 1
- // printf trace: put also the transition messages
- #define DEBUG_TRACE_CTRL 1
- // printf i2c errors
- #define DEBUG_I2C_ERR 1
- // printf i2c traffic (tx)
- //#define DEBUG_I2C_TX 1
- // printf target i2c interrupts (where the mcu is the i2c target)
- #define DEBUG_TARGET 1
- // debug temperature sensor
- //#define DEBUG_TEMPERATURE
- //------------
- // Section for configuring error tresholds
- //------------
- // soft overvoltage treshold before getting into the soft overvoltage state
- #define SOV_THRESHOLD_MV 6000
- // hard overvoltage treshold for getting into the hard overvoltage state (error)
- #define HOV_THRESHOLD_MV 8000
- // define the temperature error state
- #define OVERTEMPERATURE_TRESHOLD 43
- //------------
- // Section for configuring i2c master values
- //------------
- // dac address
- #define DAC_TARGET_ADDRESS 0x60
- // ADC base address
- // it is assumed the slots are ADC ADC_TARGET_BASE_ADDRESS slot 0,
- // other addresses follow the address table of the MCP3428
- #define ADC_TARGET_BASE_ADDRESS 0x68
- // ADC Measurement mode:
- // can be single shot or continuous
- // if used continuous, a matching delay cycles needs to be set in order to
- // ensure that the measurement is ready. (set the define to 0 if it should be one-shot)
- // (it could be the case that the channel is switched and wrong data is fetched)
- #define ADC_MEASUREMENT_IS_CONTINUOUS 1
- #define ADC_CONTINUOUS_DELAY_CYCLES_VOLTAGES (32000*10) // 32000 is 1ms (32MHz clock)
- #define ADC_CONTINUOUS_DELAY_CYCLES_SHUNT (32000*75)
- // Packet buffer sizes for RX and TX for the
- // controller mode only
- // (target for the other MCU is treated differently)
- #define I2C_TX_MAX_PACKET_SIZE 5
- #define I2C_RX_MAX_PACKET_SIZE 5
- // how many cycles do we wait until a tx message is completed?
- #define MAX_I2C_WAIT_RX 32000*10
|