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
driver_examples/spi_sdcard/main.c File Reference
#include <stdio.h>
#include <string.h>
#include "fsl_debug_console.h"
#include "fsl_dspi_master_driver.h"
#include "board.h"
#include "fsl_sdmmc_card.h"
#include "fsl_sdcard_spi.h"

Macros

#define SPI_TRANSFER_TIMEOUT
 
#define SDSPI_DEFAULT_BLOCK_SIZE
 
#define EXAMPLE_BLOCK_NUM
 
#define EXAMPLE_START_BLOCK
 
#define EXAMPLE_WRITE_LOOP_TIMES
 

Functions

uint32_t getSpiMaxFrequency (sdspi_spi_t *spi)
 
uint32_t setSpiFrequency (sdspi_spi_t *spi, uint32_t frequency)
 
uint32_t spiExchange (sdspi_spi_t *spi, const uint8_t *in, uint8_t *out, uint32_t size)
 
uint8_t spiSendWord (sdspi_spi_t *spi, uint8_t word)
 
static uint32_t fill_reference_data (uint8_t *pdata, uint8_t seed, uint32_t len)
 A function to fill a memory buffer of 'len' no of bytes with a reference data governed by a seed value. More...
 
void sdhc_card_detection (bool inserted)
 Function to indicate whether a card is detected or not. More...
 
void sdhc_cd_irqhandler (void)
 Function to be called from Card detection interrupt context etc. More...
 
static void demo_card_data_access (uint8_t instance)
 This function demonstrates read, write and erase functionalities of the card. More...
 
int main (void)
 Function prototype for main function. More...
 

Variables

uint8_t gWriteData [SDSPI_DEFAULT_BLOCK_SIZE *EXAMPLE_BLOCK_NUM]
 
uint8_t gReadData [SDSPI_DEFAULT_BLOCK_SIZE *EXAMPLE_BLOCK_NUM]
 
volatile uint32_t card_inserted
 
dspi_master_state_t g_dspiState
 
dspi_device_t g_dspiDevice
 
semaphore_t cd
 
const char * g_month_str []
 

Macro Definition Documentation

#define EXAMPLE_BLOCK_NUM
#define EXAMPLE_START_BLOCK
#define EXAMPLE_WRITE_LOOP_TIMES
#define SDSPI_DEFAULT_BLOCK_SIZE
#define SPI_TRANSFER_TIMEOUT

Function Documentation

static void demo_card_data_access ( uint8_t  instance)
static
static uint32_t fill_reference_data ( uint8_t *  pdata,
uint8_t  seed,
uint32_t  len 
)
static
uint32_t getSpiMaxFrequency ( sdspi_spi_t *  spi)
int main ( void  )

Function prototype for main function.

Function prototype for main function.

This function used the input of user as trigger to start the measurement. When user press any key, the conversion will begin, then print converted value and current temperature of the chip.

Function prototype for main function.

Run a simple application which enables watchdog, then continuously refreshes the watchdog to prevent CPU reset Upon SW1 button push, the watchdog will expire after approximately 1 seconds and chip will reset.

Function prototype for main function.

This function uses terminal to enter DAC value and convert this value to DAC output.

Function prototype for main function.

This function use DMA peripheral to transfer two buffers

Function prototype for main function.

Thid function uses DSPI master to send an array to slave and receive the array back from slave, thencompare whether the two buffers are the same.

Function prototype for main function.

This function sends back received buffer from master through DSPI interface.

Function prototype for main function.

This function sends an array through DSPI loopback interface and compare it with received buffer whether they are the same.

Function prototype for main function.

This function use EDMA peripheral to transfer two buffers

Function prototype for main function.

This function use EWM as a watchdog for an external circuit. when the counter reaches high value, EWM enter interrupt.

Function prototype for main function.

This function uses SSD to demonstrate flash mode:

  • Check flash information.
  • Erase a sector and verify.
  • Program a sector and verify.

Function prototype for main function.

This function use PWM to controll brightness of a LED. LED is brighter and then dimmer, continuously.

Function prototype for main function.

This function toogles LED1 when press SW.

Function prototype for main function.

This function uses PDB to generate a constant period of time. Each time, PDB expires, interrupt occurres.

Function prototype for main function.

Example single timer period and interrupt on multiple channels

Function prototype for main function.

This function demostrates how to use RTC as an alarm clock.

Parameters
receiveBuffBuffer used to hold received data

Return code from each SSD function

Address of the target location

Return protection status

Number of longword or phrase to be verified

0=normal, 1=user, 2=factory - margin read for reading

Indicate LED is brighter or dimmer

Use LPTMR in Time Counter mode

When hit compare value, set counter back to zero

bypass prescaler

use 1kHz Low Power Clock

< Enables slcd clock from osc

< SLCD starts fault detection and caused an LCD interrupt later

< SLCD starts blinking mode

< SLCD stops blinking mode

< SLCD starts blank display mode

< SLCD stops blank display mode

void sdhc_card_detection ( bool  inserted)
void sdhc_cd_irqhandler ( void  )
uint32_t setSpiFrequency ( sdspi_spi_t *  spi,
uint32_t  frequency 
)
uint32_t spiExchange ( sdspi_spi_t *  spi,
const uint8_t *  in,
uint8_t *  out,
uint32_t  size 
)
uint8_t spiSendWord ( sdspi_spi_t *  spi,
uint8_t  word 
)

Variable Documentation

volatile uint32_t card_inserted
semaphore_t cd
dspi_device_t g_dspiDevice
dspi_master_state_t g_dspiState
const char* g_month_str[]