| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- // 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 (32000000*5)
- // i2c address for acting as target
- // (based on the GPIO 1 integer is added)
- #define I2C_TARGET_BASE_ADDRESS 0x48
- //------------
- // 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
- //------------
- // 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,
- // ADC_TARGET_BASE_ADDRESS+1 slot 1, etc.
- #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 (32000) // 32000 is 1ms (32MHz clock)
- // 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
|