CLEON  Version 1
Cloud-Offloaded GPS Receiver
sys_mmc.h File Reference

Micro SD card related functions. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SYS_MMC_LED_INDICATION_FOR_ERROR   _ENABLE_
 
#define SYS_MMC_IsMicroSDInserted()   !((MICROSD_STATUS_PORT(IN) & BV(MICROSD_STATUS_PIN)) >> MICROSD_STATUS_PIN)
 

Functions

void SYS_MMC_Init (void)
 Initializing microcontroller.
 
void SYS_MMC_InitIO (void)
 Initializing Micro SD interface pins.
 
void SYS_MMC_FastMode (void)
 Enable fast SD card SPI transfer.
 
void SYS_MMC_ReadFrame (unsigned char *ptrucBuffer, unsigned int uiSize)
 Read a frame of bytes via SPI.
 
void SYS_MMC_SendFrame (unsigned char *ptrucBuffer, unsigned int uiSize)
 Send a frame of bytes via SPI.
 
void SYS_MMC_DeselectCard (void)
 Set the SD Card's chip-select signal to high.
 
void SYS_MMC_SelectCard (void)
 Set the SD Card's chip-select signal to low.
 

Detailed Description

Micro SD card related functions.

Definition in file sys_mmc.h.

Macro Definition Documentation

#define SYS_MMC_IsMicroSDInserted ( )    !((MICROSD_STATUS_PORT(IN) & BV(MICROSD_STATUS_PIN)) >> MICROSD_STATUS_PIN)

Definition at line 12 of file sys_mmc.h.

#define SYS_MMC_LED_INDICATION_FOR_ERROR   _ENABLE_

Definition at line 10 of file sys_mmc.h.

Function Documentation

void SYS_MMC_DeselectCard ( void  )

Set the SD Card's chip-select signal to high.

Returns
void
Parameters
void

Definition at line 174 of file sys_mmc.c.

void SYS_MMC_FastMode ( void  )

Enable fast SD card SPI transfer.

Returns
void
Parameters
void

Definition at line 99 of file sys_mmc.c.

{
UCB1CTL1 |= UCSWRST; // Put state machine in reset
UCB1BR0 = 2; // f_UCxCLK = 12MHz/2 = 6MHz
UCB1BR1 = 0;
UCB1CTL1 &= ~UCSWRST; // Release USCI state machine
}
void SYS_MMC_Init ( void  )

Initializing microcontroller.

Returns
void
Parameters
void

Definition at line 28 of file sys_mmc.c.

{
// Check if MicroSD is inserted
#if SYS_MMC_LED_INDICATION_FOR_ERROR == _ENABLE_
#endif
// Initializing file system
// Mount FatFs moudle
// Create directory named 'CLEON'
FS_MakeDir("CLEON");
// Change directory to 'CLEON'
FS_ChangeDir("/CLEON");
}else{
#if SYS_MMC_LED_INDICATION_FOR_ERROR == _ENABLE_
#endif
}
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SYS_MMC_ReadFrame ( unsigned char *  ptrucBuffer,
unsigned int  uiSize 
)

Read a frame of bytes via SPI.

Returns
void
Parameters
ptrucBuffer- Place to store the received bytes
uiSize- Indicator of how many bytes to read

Definition at line 116 of file sys_mmc.c.

{
unsigned int uiGIE = __get_SR_register() & GIE; //Store current GIE state
__disable_interrupt(); //Make this operation atomic
UCB1IFG &= ~UCRXIFG; //Ensure RXIFG is clear
//Clock the actual data transfer and receive the bytes
while (uiSize--){
while (!(UCB1IFG & UCTXIFG)) ; //Wait while not ready for TX
UCB1TXBUF = 0xff; //Write dummy byte
while (!(UCB1IFG & UCRXIFG)) ; //Wait for RX buffer (full)
*ptrucBuffer++ = UCB1RXBUF;
}
__bis_SR_register(uiGIE); //Restore original GIE state
}
void SYS_MMC_SelectCard ( void  )

Set the SD Card's chip-select signal to low.

Returns
void
Parameters
void

Definition at line 187 of file sys_mmc.c.

void SYS_MMC_SendFrame ( unsigned char *  ptrucBuffer,
unsigned int  uiSize 
)

Send a frame of bytes via SPI.

Returns
void
Parameters
ptrucBuffer- Place that holds the bytes to send
uiSize- Indicator of how many bytes to send

Definition at line 144 of file sys_mmc.c.

{
unsigned int uiGIE = __get_SR_register() & GIE; //Store current GIE state
__disable_interrupt(); //Make this operation atomic
//Clock the actual data transfer and send the bytes. Note that we
//intentionally not read out the receive buffer during frame transmission
//in order to optimize transfer speed, however we need to take care of the
//resulting overrun condition.
while (uiSize--){
while (!(UCB1IFG & UCTXIFG)) ; //Wait while not ready for TX
UCB1TXBUF = *ptrucBuffer++; //Write byte
}
while (UCB1STAT & UCBUSY) ; //Wait for all TX/RX to finish
UCB1RXBUF; //Dummy read to empty RX buffer
//and clear any overrun conditions
__bis_SR_register(uiGIE); //Restore original GIE state
}