diff --git a/samples/drivers/dac/README.rst b/samples/drivers/dac/README.rst index 96577071b1f..c00dfa47023 100644 --- a/samples/drivers/dac/README.rst +++ b/samples/drivers/dac/README.rst @@ -13,7 +13,30 @@ Building and Running The DAC output is defined in the board's devicetree and pinmux file. -Only board nucleo_l073rz is supported for now. +Building and Running for ST Nucleo L073RZ +========================================= +The sample can be built and executed for the +:ref:`nucleo_l073rz_board` as follows: + +.. zephyr-app-commands:: + :zephyr-app: samples/drivers/dac + :board: nucleo_l073rz + :goals: build flash + :compact: + +Building and Running for NXP TWR-KE18F +====================================== +The sample can be built and executed for the :ref:`twr_ke18f` as +follows: + +.. zephyr-app-commands:: + :zephyr-app: samples/drivers/dac + :board: twr_ke18f + :goals: build flash + :compact: + +DAC output is available on pin A32 of the primary TWR elevator +connector. Sample output ============= @@ -26,7 +49,6 @@ The following output is printed: .. code-block:: console - DAC internal reference voltage: 3300 mV Generating sawtooth signal at DAC channel 1. .. note:: If the DAC is not supported, the output will be an error message. diff --git a/samples/drivers/dac/sample.yaml b/samples/drivers/dac/sample.yaml index dbebcabe9c3..2bd996a696c 100644 --- a/samples/drivers/dac/sample.yaml +++ b/samples/drivers/dac/sample.yaml @@ -3,6 +3,7 @@ sample: tests: sample.drivers.dac: tags: DAC + platform_whitelist: nucleo_l073rz twr_ke18f depends_on: dac harness: console harness_config: diff --git a/samples/drivers/dac/src/main.c b/samples/drivers/dac/src/main.c index 11c740056ac..66d1605a104 100644 --- a/samples/drivers/dac/src/main.c +++ b/samples/drivers/dac/src/main.c @@ -8,9 +8,17 @@ #include #include +#if defined(CONFIG_BOARD_NUCLEO_L073RZ) #define DAC_DEVICE_NAME DT_LABEL(DT_ALIAS(dac1)) #define DAC_CHANNEL_ID 1 #define DAC_RESOLUTION 12 +#elif defined(CONFIG_BOARD_TWR_KE18F) +#define DAC_DEVICE_NAME DT_LABEL(DT_NODELABEL(dac0)) +#define DAC_CHANNEL_ID 0 +#define DAC_RESOLUTION 12 +#else +#error "Unsupported board." +#endif static const struct dac_channel_cfg dac_ch_cfg = { .channel_id = DAC_CHANNEL_ID,