Mozzi  version v2.0
sound synthesis library for Arduino
config_checks_samd21.h
1 /*
2  * config_checks_samd21.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_SAMD21_H
13 #define CONFIG_CHECK_SAMD21_H
14 
15 /**
16  * @page hardware_samd Mozzi on SAMD21 based boards (Arduino Circuitplayground M0 and others)
17  *
18  * port by Adrian Freed
19  *
20  * @section samd_status Port status and notes
21  * - @def MOZZI_ANALOG_READ and MOZZI_ANALOG_INPUT are not implemented (contributions welcome)
22  * - We don't have a lot of data, which boards this port has been tested on. Success or not, let us know, if you are using Mozzi on SAMD21 boards
23  *
24  * @section samd_output_modes Output modes
25  * The following audio modes (see @ref MOZZI_AUDIO_MODE) are currently supported on this hardware:
26  * - MOZZI_OUTPUT_EXTERNAL_TIMED
27  * - MOZZI_OUTPUT_EXTERNAL_CUSTOM
28  * - MOZZI_OUTPUT_INTERNAL_DAC
29  *
30  * The default mode is @ref samd_internal_dac , meaning, only boards with an inbuilt DAC are covered by default
31  * (you could stil use one of the external output modes, however).
32  *
33  * @section samd_internal_dac MOZZI_OUTPUT_INTERNAL_DAC
34  * Output resolution is 10 bits by default, and goes to pin DAC0. Only mono output is supported. Within the hardware limits of your board, you can configure the following:
35  *
36  * @code
37  * #define MOZZI_AUDIO_PIN_1 ... // default is DAC0
38  * #define MOZZI_AUDIO_BITS ... // default is 10
39  * @endcode
40  *
41  * @section samd_external MOZZI_OUTPUT_EXTERNAL_TIMED and MOZZI_OUTPUT_EXTERNAL_CUSTOM
42  * See @ref external_audio
43 */
44 
45 #if not IS_SAMD21()
46 #error This header should be included for SAMD21 architecture (Arduino Circuitplayground M0 and others), 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_NONE
65 #endif
66 
67 MOZZI_CHECK_SUPPORTED(MOZZI_ANALOG_READ, MOZZI_ANALOG_READ_NONE)
68 
69 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_INTERNAL_DAC)
70 # if !defined(MOZZI_AUDIO_BITS)
71 # define MOZZI_AUDIO_BITS 10
72 # endif
73 # if !defined(MOZZI_AUDIO_PIN_1)
74 # define MOZZI_AUDIO_PIN_1 DAC0
75 # endif
76 # include "disable_stereo_on_github_workflow.h"
77 MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_CHANNELS, 1)
78 #endif
79 
80 #define MOZZI__INTERNAL_ANALOG_READ_RESOLUTION 12
81 
82 #endif // #ifndef CONFIG_CHECK_SAMD21_H