You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.6KB

  1. // Copyright 2012 Olivier Gillet.
  2. //
  3. // Author: Olivier Gillet (olivier@mutable-instruments.net)
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. #ifndef EDGES_HARDWARE_CONFIG_H_
  16. #define EDGES_HARDWARE_CONFIG_H_
  17. #include "avrlibx/avrlibx.h"
  18. #include "avrlibx/devices/switch.h"
  19. #include "avrlibx/io/gpio.h"
  20. #include "avrlibx/io/parallel_io.h"
  21. #include "avrlibx/io/ring_buffer.h"
  22. #include "avrlibx/io/usart.h"
  23. #include "avrlibx/io/usart_spi.h"
  24. #include "avrlibx/system/timer.h"
  25. namespace edges {
  26. using avrlibx::DualTimer;
  27. using avrlibx::Gpio;
  28. using avrlibx::ParallelPort;
  29. using avrlibx::PortA;
  30. using avrlibx::PortB;
  31. using avrlibx::PortC;
  32. using avrlibx::PortD;
  33. using avrlibx::PortE;
  34. using avrlibx::PWM;
  35. using avrlibx::RingBuffer;
  36. using avrlibx::SPIMaster;
  37. using avrlibx::Timer;
  38. using avrlibx::UsartSPIMaster;
  39. // MIDI
  40. typedef avrlibx::Usart<
  41. PortC,
  42. 0,
  43. 31250,
  44. avrlibx::RX_POLLED,
  45. avrlibx::TX_DISABLED> MidiIO;
  46. struct MidiBufferSpecs {
  47. typedef uint8_t Value;
  48. enum {
  49. buffer_size = 128,
  50. data_size = 8,
  51. };
  52. };
  53. typedef RingBuffer<MidiBufferSpecs> MidiBuffer;
  54. // IO
  55. typedef ParallelPort<PortA, 0, 3> GateInputs;
  56. typedef ParallelPort<PortA, 4, 7> Leds;
  57. typedef ParallelPort<PortB, 0, 3> Switches;
  58. typedef Gpio<PortE, 0> SyncSwitch;
  59. // Audio DAC
  60. typedef Gpio<PortC, 6> DACSS;
  61. typedef UsartSPIMaster<
  62. PortC, 1,
  63. DACSS, avrlibx::MSB_FIRST, 2> AudioDACInterface;
  64. // ADC
  65. typedef Gpio<PortD, 3> ADCSS;
  66. typedef SPIMaster<
  67. PortD, ADCSS,
  68. avrlibx::MSB_FIRST,
  69. avrlibx::SPI_PRESCALER_CLK_16> ADCInterface;
  70. // Timers
  71. typedef Timer<PortC, 0> Channel3Timer;
  72. typedef Timer<PortC, 1> Channel2Timer;
  73. typedef Timer<PortD, 0> Channel1Timer;
  74. typedef Timer<PortD, 1> Channel0Timer;
  75. typedef PWM<PortC, 0> Channel3;
  76. typedef PWM<PortC, 4> Channel2;
  77. typedef PWM<PortD, 0> Channel1;
  78. typedef PWM<PortD, 4> Channel0;
  79. typedef Timer<PortE, 0> AudioRateTimer;
  80. const uint8_t kNumChannels = 4;
  81. #ifdef OCTAL_ADC
  82. const uint8_t kNumAdcChannels = 8;
  83. #else
  84. const uint8_t kNumAdcChannels = 4;
  85. #endif
  86. } // namespace edges
  87. #endif // EDGES_HARDWARE_CONFIG_H_