YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
max98357_rp2350_drv.h
1// ---------------------------------------------
2// This file is part of
3// _ _ __ _ _ __ __
4// ( \/ ) /__\ ( )_( ) /__\ ( )
5// \ / /(__)\ ) _ ( /(__)\ )(__
6// (__)(__)(__)(_) (_)(__)(__)(____)
7//
8// Yet Another HW Abstraction Library
9// Copyright (C) Andreas Terstegge
10// BSD Licensed (see file LICENSE)
11//
12// ---------------------------------------------
13//
14#ifndef _MAX98357_RP2350_DRV_H_
15#define _MAX98357_RP2350_DRV_H_
16
17#include <cstdint>
18#include "pcm_audio_interface.h"
19#include "gpio_rp2350.h"
20#include "pio_rp2350.h"
21#include "FIFO.h"
22
24{
25public:
26 max98357_rp2350_drv(gpio_pin_t din_pin,
27 gpio_pin_t bclk_pin,
28 gpio_pin_t lrclk_pin,
29 gpio_pin_t sd_pin);
30
31 virtual ~max98357_rp2350_drv() = default;
32
33 inline void shutdown(bool v) {
34 _sd.gpioWrite(!v);
35 }
36
37 void setPcmRate(uint32_t Hz = 44100) override;
38
39private:
40 gpio_rp2350 _sd; // Shutdown Pin (also channel select)
41 SM * _pcm_sm; // The PIO State Machine
42 gpio_rp2350 _edge;
43};
44
45#endif // _MAX98357_RP2040_DRV_H_