YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
pcm_pwm_rp2040_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 _PCM_PWM_RP2040_DRV_H_
15#define _PCM_PWM_RP2040_DRV_H_
16
17#include <cstdint>
18#include "pcm_audio_interface.h"
19#include "gpio_rp2040.h"
20#include "timer_rp2040.h"
21#include "RP2040.h"
22
23using namespace _PWM_;
24
26public:
27 pcm_pwm_rp2040_drv(gpio_pin_t left, gpio_pin_t right);
28
29 virtual ~pcm_pwm_rp2040_drv() = default;
30
31 void enable_output(bool v);
32
33 void setPcmRate(uint32_t Hz = 44100) override;
34
35 inline void timer_reset() { _pcm_timer.reset(); }
36
37private:
38 timer_rp2040 _pcm_timer;
39 bool _left_is_pwm_b;
40 bool _right_is_pwm_b;
41 CH_CSR_t * _left_pwm_csr;
42 CH_CC_t * _left_pwm_cc;
43 CH_CSR_t * _right_pwm_csr;
44 CH_CC_t * _right_pwm_cc;
45};
46
47#endif // _PCM_PWM_RP2040_DRV_H_
CMSIS-Core(M) Device Peripheral Access Layer Header File for Device RP2040.