config.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // globals definition
  2. //------------------------
  3. // Configuration section
  4. // How many slots do we currently support?
  5. // use 1 for debugging, 4 for production
  6. #define NUM_SLOTS 4
  7. //Battery Tolerance
  8. // how much tolerance do we allow if we charge / discharge before we
  9. // trigger the control loop to adjust the value
  10. #define BATTERY_CURRENT_THRESHOLD 5
  11. // Mainloop sleep time
  12. // Time to sleep between two mainloop intervals
  13. // We have a 32 MHz clock
  14. // debugging e.g. 32000000*5 -> 5s
  15. // production e.g. 320000 (10ms) (Validate that this is really the case!)
  16. // should be large for debugging, (e.g. )
  17. // small for production
  18. #define MAINLOOP_DELAY (32000000*5)
  19. // i2c address for acting as target
  20. // (based on the GPIO 1 integer is added)
  21. #define I2C_TARGET_BASE_ADDRESS 0x48
  22. //------------
  23. // Section for configuring debugging outputs
  24. //------------
  25. // printf ADC outputs
  26. #define DEBUG_ADC 1
  27. // printf DAC outputs
  28. #define DEBUG_DAC 1
  29. // printf control loop outputs
  30. #define DEBUG_CTRL 1
  31. // printf trace: put also the transition messages
  32. #define DEBUG_TRACE_CTRL 1
  33. // printf i2c errors
  34. #define DEBUG_I2C_ERR 1
  35. // printf i2c traffic (tx)
  36. #define DEBUG_I2C_TX 1
  37. // printf target i2c interrupts (where the mcu is the i2c target)
  38. #define DEBUG_TARGET 1
  39. //------------
  40. // Section for configuring error tresholds
  41. //------------
  42. // soft overvoltage treshold before getting into the soft overvoltage state
  43. #define SOV_THRESHOLD_MV 6000
  44. // hard overvoltage treshold for getting into the hard overvoltage state (error)
  45. #define HOV_THRESHOLD_MV 8000
  46. // define the temperature error state
  47. #define OVERTEMPERATURE_TRESHOLD 43
  48. //------------
  49. // Section for configuring i2c master values
  50. //------------
  51. // dac address
  52. #define DAC_TARGET_ADDRESS 0x60
  53. // ADC base address
  54. // it is assumed the slots are ADC ADC_TARGET_BASE_ADDRESS slot 0,
  55. // ADC_TARGET_BASE_ADDRESS+1 slot 1, etc.
  56. #define ADC_TARGET_BASE_ADDRESS 0x68
  57. // ADC Measurement mode:
  58. // can be single shot or continuous
  59. // if used continuous, a matching delay cycles needs to be set in order to
  60. // ensure that the measurement is ready. (set the define to 0 if it should be one-shot)
  61. // (it could be the case that the channel is switched and wrong data is fetched)
  62. #define ADC_MEASUREMENT_IS_CONTINUOUS 1
  63. #define ADC_CONTINUOUS_DELAY_CYCLES (32000) // 32000 is 1ms (32MHz clock)
  64. // Packet buffer sizes for RX and TX for the
  65. // controller mode only
  66. // (target for the other MCU is treated differently)
  67. #define I2C_TX_MAX_PACKET_SIZE 5
  68. #define I2C_RX_MAX_PACKET_SIZE 5