| Kinetis SDK Demo Applications User Guide 1.0.0-beta Freescale Semiconductor, Inc.

- Main Page
- Related Pages
- Demos

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
adc_period_sample/src/main.c File Reference
`#include <string.h>`
`#include <stdio.h>`
`#include "device/fsl_device_registers.h"`
`#include "fsl_debug_uart.h"`
`#include "fsl_gpio_hal.h"`
`#include "fsl_port_hal.h"`
`#include "fsl_pit_driver.h"`
`#include "fsl_adc_driver.h"`
`#include "fsl_interrupt_manager.h"`
`#include "fsl_clock_manager.h"`
`#include "fsl_os_abstraction.h"`
`#include "board.h"`

## Data Structures
struct | sparse_node_ptr
| Define the sparse matrix node for display wave. More...

## Macros
#define | ADC_INST
#define | MAX_CONSOLE_COL
#define | NR_SAMPLES
#define | FREQ_INPUT
#define | MAX_AMPLITUDE
#define | DEBUG_UART_BAUD

## Functions
static void | adc_isr_callback (void)
| ADC0 interrupt handler for fetching sample data. More...
static int32_t | init_adc (uint32_t instance)
| Initialize the ADC0 for HW trigger. More...
static void | init_pit_period (void)
| Initialize the PIT for period trigger. More...
void | sparse_reset (void)
| Reset the sparse matrix. More...
void | sparse_insert (uint32_t index, uint32_t value)
| insert a node into the sparse matrix More...
void | main (void)
| Main demo function. More...

## Variables
static sync_object_t | adc_result_sync
static uint16_t | result
static sparse_node_ptr | chart_head [MAX_AMPLITUDE]
static sparse_node_t | chart_nodes [NR_SAMPLES]
static uint32_t | free_node

## Data Structure Documentation

struct sparse_node_t

Data Fields
struct sparse_node * | next | next node
uint32_t | value | the sample index

## Macro Definition Documentation

#define ADC_INST

ADC instance

#define DEBUG_UART_BAUD

debug uart baudrate

#define FREQ_INPUT

input signal frequency, defult: 50HZ

#define MAX_AMPLITUDE

print chart for the sampled data

#define MAX_CONSOLE_COL

the console max column size

#define NR_SAMPLES

number of samples in one period

## Function Documentation

static void adc_isr_callback | ( | void |  | ) |
| static

static int32_t init_adc | ( | uint32_t | instance | ) |
| static

Parameters

  instance | The ADC instance number

static void init_pit_period | ( | void |  | ) |
| static

void main | ( | void |  | ) |

void sparse_insert | ( | uint32_t | index,
|  | uint32_t | value
| ) |  |

Parameters

  index | The amplitude index
  value | The sample count value

void sparse_reset | ( | void |  | ) |

## Variable Documentation

sync_object_t adc_result_sync
| static

sync object for adc convert result

sparse_node_ptr chart_head[MAX_AMPLITUDE]
| static

sparse matrix head

sparse_node_t chart_nodes[NR_SAMPLES]
| static

sparse matrix nodes

uint32_t free_node
| static

free node slot index for chart_nodes[]

uint16_t result
| static

result from ADC Rn