Kinetis SDK v.1.2 Demo Applications User's Guide  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dac_cadc_demo/demo_state_machine.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  */
31 
32 #ifndef __TERMINAL_MENU_H__
33 #define __TERMINAL_MENU_H__
34 // Includes
37 
38 // Standard C Included Files
39 #include <stdint.h>
40 // SDK Included Files
41 #include "fsl_dac_driver.h"
42 #include "fsl_cadc_driver.h"
43 #include "fsl_uart_driver.h"
44 #include "fsl_debug_console.h"
45 #include "board.h"
46 
48 // Definitions
50 
51 #define DAC_1_0_VOLTS 1241U
52 #define DAC_1_5_VOLTS 1862U
53 #define DAC_2_0_VOLTS 2482U
54 #define DAC_2_5_VOLTS 3103U
55 #define DAC_3_0_VOLTS 3724U
56 
57 #define VREF_BRD 3.300
58 #define SE_12BIT 4096.0
59 
60 typedef enum Demo_States
61 {
71 
72 typedef struct Demo_StateMachine
73 {
74  demo_state_t state;
75  uint8_t (*demo_func)(demo_state_t *prevState);
77 
79 // Prototypes
81 
89 uint8_t demo_start(demo_state_t *prevState);
90 
98 uint8_t device_config(demo_state_t *prevState);
99 
107 uint8_t dac_set(demo_state_t *prevState);
108 
116 uint8_t wait_state(demo_state_t *prevState);
117 
125 uint8_t adc_get(demo_state_t *prevState);
126 
134 uint8_t device_deinit(demo_state_t *prevState);
135 
143 uint8_t demo_end(demo_state_t *prevState);
144 
145 #endif /* __TERMINAL_MENU_H__ */
Definition: dac_adc_demo/demo_state_machine.h:65
Definition: dac_adc_demo/demo_state_machine.h:69
uint8_t device_deinit(demo_state_t *prevState)
Function deinitializes the DAC and ADC module following a user command to do terminate demo...
Definition: dac_adc_demo/demo_state_machine.c:313
Definition: dac_adc_demo/demo_state_machine.h:62
Definition: dac_adc_demo/demo_state_machine.h:64
uint8_t device_config(demo_state_t *prevState)
Function configure DAC and ADC. DAC is configured for software updates. The ADC is set in &#39;Blocking M...
Definition: dac_adc_demo/demo_state_machine.c:106
demo_state_t
Definition: dac_adc_demo/demo_state_machine.h:60
Definition: dac_adc_demo/demo_state_machine.h:66
uint8_t wait_state(demo_state_t *prevState)
Function to perform a wait and possible state change based on *prevState.
Definition: dac_adc_demo/demo_state_machine.c:227
uint8_t demo_start(demo_state_t *prevState)
Function to print out welcome message and pins required by demo.
Definition: dac_adc_demo/demo_state_machine.c:72
Definition: dac_adc_demo/demo_state_machine.h:63
uint8_t demo_end(demo_state_t *prevState)
Function indicates to the user that the demo has been terminated.
Definition: dac_adc_demo/demo_state_machine.c:333
uint8_t adc_get(demo_state_t *prevState)
Function to get ADC values from channel connected to DAC output.
Definition: dac_adc_demo/demo_state_machine.c:252
Definition: dac_adc_demo/demo_state_machine.h:67
Definition: dac_adc_demo/demo_state_machine.h:68
uint8_t dac_set(demo_state_t *prevState)
Function sets output level on DAC.
Definition: dac_adc_demo/demo_state_machine.c:170
Definition: dac_adc_demo/demo_state_machine.h:72