PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
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.

69 lines
2.5KB

  1. /***************************************************
  2. This is an example for the Adafruit VS1053 Codec Breakout
  3. Designed specifically to work with the Adafruit VS1053 Codec Breakout
  4. ----> https://www.adafruit.com/products/1381
  5. Adafruit invests time and resources providing this open source code,
  6. please support Adafruit and open-source hardware by purchasing
  7. products from Adafruit!
  8. Written by Limor Fried/Ladyada for Adafruit Industries.
  9. BSD license, all text above must be included in any redistribution
  10. ****************************************************/
  11. #include <SPI.h>
  12. #include <Adafruit_VS1053.h>
  13. #include <SD.h>
  14. // These are the pins used for the breakout example
  15. #define BREAKOUT_RESET 9 // VS1053 reset pin (output)
  16. #define BREAKOUT_CS 10 // VS1053 chip select pin (output)
  17. #define BREAKOUT_DCS 8 // VS1053 Data/command select pin (output)
  18. // These are the pins used for the music maker shield
  19. #define SHIELD_RESET -1 // VS1053 reset pin (unused!)
  20. #define SHIELD_CS 7 // VS1053 chip select pin (output)
  21. #define SHIELD_DCS 6 // VS1053 Data/command select pin (output)
  22. // These are common pins between breakout and shield
  23. #define CARDCS 4 // Card chip select pin
  24. // DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
  25. #define DREQ 3 // VS1053 Data request, ideally an Interrupt pin
  26. Adafruit_VS1053_FilePlayer musicPlayer =
  27. // create breakout-example object!
  28. Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS);
  29. // create shield-example object!
  30. //Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
  31. void setup() {
  32. Serial.begin(9600);
  33. Serial.println("VS1053 GPIO test");
  34. // disable the card (we won't be using it)
  35. pinMode(CARDCS, OUTPUT);
  36. digitalWrite(CARDCS, HIGH);
  37. // initialise the music player
  38. if (!musicPlayer.begin()) {
  39. Serial.println("VS1053 not found");
  40. while (1); // don't do anything more
  41. }
  42. musicPlayer.sineTest(0x44, 500); // Make a tone to indicate VS1053 is working
  43. }
  44. void loop() {
  45. for (uint8_t i=0; i<8; i++) {
  46. musicPlayer.GPIO_pinMode(i, OUTPUT);
  47. musicPlayer.GPIO_digitalWrite(i, HIGH);
  48. Serial.print("GPIO: "); Serial.println(musicPlayer.GPIO_digitalRead(i));
  49. musicPlayer.GPIO_digitalWrite(i, LOW);
  50. Serial.print("GPIO: "); Serial.println(musicPlayer.GPIO_digitalRead(i));
  51. musicPlayer.GPIO_pinMode(i, INPUT);
  52. delay(100);
  53. }
  54. }