Mozzi  version v2.0
sound synthesis library for Arduino
config_checks_renesas.h
1 /*
2  * config_checks_renesas.h
3  *
4  * This file is part of Mozzi.
5  *
6  * Copyright 2023-2024 Thomas Friedrichsmeier and the Mozzi Team
7  *
8  * Mozzi is licensed under the GNU Lesser General Public Licence (LGPL) Version 2.1 or later.
9  *
10 */
11 
12 #ifndef CONFIG_CHECK_RENESAS_H
13 #define CONFIG_CHECK_RENESAS_H
14 
15 /**
16  * @page hardware_renesas Mozzi on Arduino Uno R4 - Renesas.
17  *
18  * port by Thomas Combriat
19  *
20  * @section renesas_status Port status and notes
21  * Compiles and runs using Arduino's standard library (Renesas 0.8.7 at the time of this writing).
22  *
23  * A few particularities:
24  * - Because this board has an on-board DAC (A0), but only one, STEREO is not implemented and Mozzi uses this pin. Usage of other pins using PWM for instance is not implemented yet.
25  * - getAudioInput() and mozziAnalogRead() return values in the Renesas' full ADC resolution of 0-16384 rather than AVR's 0-1023. *This might change in the near future for speed purposes.*
26  *
27  * @section rensesas_output Output modes
28  * The following audio modes (see @ref MOZZI_AUDIO_MODE) are currently supported on this hardware:
29  * - MOZZI_OUTPUT_EXTERNAL_TIMED
30  * - MOZZI_OUTPUT_EXTERNAL_CUSTOM
31  * - MOZZI_OUTPUT_INTERNAL_DAC
32  *
33  * The default mode is @ref renesas_internal_dac. Further modes may be added in the future.
34  *
35  * @section renesas_internal_dac MOZZI_OUTPUT_INTERNAL_DAC
36  * This uses the inbuild DAC on the board on pin A0. Mono output only, and the pin is not configurable. Audio resolution is also fixed at 12 bits (which is what the board supports).
37  *
38  * This mode claims two timers (but it is not hardcoded, which ones).
39  *
40  * @section renesas_external MOZZI_OUTPUT_EXTERNAL_TIMED and MOZZI_OUTPUT_EXTERNAL_CUSTOM
41  * MOZZI_OUTPUT_EXTERNAL_TIMED claimes one timer, MOZZI_OUTPUT_EXTERNAL_CUSTOM does not claim any timer.
42  * See @ref external_audio
43 */
44 
45 #if not IS_RENESAS()
46 #error This header should be included for RENESAS (Arduino Uno R4) architecture, only
47 #endif
48 
50 #if !defined(MOZZI_AUDIO_MODE)
51 #define MOZZI_AUDIO_MODE MOZZI_OUTPUT_INTERNAL_DAC
52 #endif
53 MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_EXTERNAL_TIMED, MOZZI_OUTPUT_EXTERNAL_CUSTOM, MOZZI_OUTPUT_INTERNAL_DAC)
54 
55 #if !defined(MOZZI_AUDIO_RATE)
56 #define MOZZI_AUDIO_RATE 32768
57 #endif
58 
59 #if defined(MOZZI_PWM_RATE)
60 #error Configuration of MOZZI_PWM_RATE is not currently supported on this platform (always same as MOZZI_AUDIO_RATE)
61 #endif
62 
63 #if !defined(MOZZI_ANALOG_READ)
64 # define MOZZI_ANALOG_READ MOZZI_ANALOG_READ_STANDARD
65 #endif
66 
67 MOZZI_CHECK_SUPPORTED(MOZZI_ANALOG_READ, MOZZI_ANALOG_READ_NONE, MOZZI_ANALOG_READ_STANDARD)
68 
69 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_INTERNAL_DAC)
70 # if !defined(MOZZI_AUDIO_BITS)
71 # define MOZZI_AUDIO_BITS 12
72 # endif
73 # if !defined(MOZZI_AUDIO_PIN_1)
74 # define MOZZI_AUDIO_PIN_1 A0
75 # endif
76 # define BYPASS_MOZZI_OUTPUT_BUFFER true
77 # include "disable_stereo_on_github_workflow.h"
78 MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_CHANNELS, 1)
79 #endif
80 
81 #define MOZZI__INTERNAL_ANALOG_READ_RESOLUTION 14
82 
83 #endif // #ifndef CONFIG_CHECK_RENESAS_H