weAut_01 / weAutSys    R 2.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Data Structures | Defines | Functions | Variables
include/we-aut_sys/smc.h File Reference

Overview

weAutSys' (low level) system calls, services and types for communication with a small memory card

This file contains the definitions for weAutSys' (low level) system calls, services and types to communicate via SPI with a small memory card.

This is system software and must not be modified for user or application programs.

This file is part of weAutSys   <weinert-automation.de>

  Copyright © 2012 Albrecht Weinert, Bochum

Author:
Albrecht Weinert   <a-weinert.de>
Revision:
2
Date:
2017-01-25 17:49:03 +0100 (Mi, 25 Jan 2017)

Data Structures

struct  smcThr_data_t
 The organisational data for a small memory card (SMC) handling thread. More...

Defines

#define APP_CMD   55
 SMC command: next command is application specific.
#define CT_HC   0x08
 Card type flag: high capacity.
#define CT_INS_POWD   0x30
 Card type mask: power & inserted.
#define CT_INSERTED   0x20
 Card type flag: inserted.
#define CT_OPCN_MASK   0xF0
 Card type mask: operation bits.
#define CT_POWERD_UP   0x10
 Card type flag: was powered up.
#define CT_TYPE_MASK   0x0F
 Card type mask: type bits.
#define CT_V_1   0x02
 Card type: SD version 2.
#define CT_V_2   0x04
 Card type: SD version 2.
#define CT_V_3   0x01
 Card type: MMC version 3.
#define FL_CAT   0x40
 Action/state flag: card type.
#define FL_IMP   0x76
 Action mask: implemented actions (except Bit 7)
#define FL_INI   0xF0
 Action mask: initialisation actions.
#define FL_R_W   0x06
 Action mask: sector access (read, write)
#define FL_RDS   0x02
 Action/state flag: sector read.
#define FL_WRS   0x04
 Action/state flag: sector write.
#define GO_IDLE_STATE   0
 SMC command: soft reset.
#define LOCK_UNLOCK   42
 SMC command: lock / unlock the card.
#define NCR_EXTR_WAIT   8
 Maximum extra waits for command response.
#define othersAskPrio()
 Other devices asks for priority.
#define READ_OCR   58
 SMC command: read the card's OCR register (R3)
#define READ_SINGLE_BLOCK   17
 SMC command: read one block.
#define SEND_CID
 SMC command: get CID.
#define SEND_CID
 SMC command: get CID.
#define SEND_CSD   9
 SMC command: send card specific data.
#define SEND_IF_COND   8
 SMC command: send interface condition.
#define SEND_OP_COND   1
 SMC command: init. process.
#define SEND_OP_COND_APP
 SMC application specific command: initialisation process.
#define SEND_STATUS   13
 SMC command: get status (R2)
#define SET_BLOCKLEN   16
 SMC command: set block length for LOCK_UNLOCK.
#define SMC_DAT_TOK   0xFE
 data token
#define SMC_LAST_R1
 Last command response - first or single (R1) byte.
#define SMC_SEC_BUF_SZ   516
 Sector buffer size.
#define smcInsPow()
 Inserted card is powered up.
#define smcReceive()
 Receive a single byte from the small memory card.
#define smcReceiveN(receiveB, skip, n)
 Receive n bytes from the SMC to a buffer with optional skip.
#define smcTypeD()
 The SMC's type is determined and OCR is known.
#define smcXmit(datByte)
 Transmit a single byte to the small memory card.
#define smcXmit2(sendB1, sendB2)
 Send two bytes and receive one byte to/from the small memory card.
#define WRITE_BLOCK   24
 SMC command: write one block.

Functions

uint8_t checkBusy (uint8_t tries)
 Check if card is busy.
void clk80 (void)
 Have 80 dummy SPI clocks.
uint8_t crc7stp (uint8_t crcIn, uint8_t datByte) __attribute__((always_inline))
 Calculate CRC7 (one step)
void deSelectSMC (void) __attribute__((always_inline))
 De-select the small memory card.
uint8_t doSectorRead (uint32_t sector)
 Order sector read (as background task)
uint8_t doSectorSync (void)
 Order sector synchronisation (as background task)
uint8_t getSMCtype (void)
 Determine the card type.
void initSMCthreadState (uint8_t actionFlag)
 Initialise the small memory card (smc) handling thread.
uint8_t readDataBlock (uint32_t sector, uint8_t *buff)
 Read single data block (512 byte)
uint8_t sendAppCmd (uint8_t appCmdNum, uint32_t cmdArg)
 Send an application specific command to the small memory card.
uint8_t sendCmd (uint8_t cmdNum, uint32_t cmdArg)
 Send a command to the small memory card.
uint8_t sendCmd0arg (uint8_t cmdNum)
 Send a command with 0 argument to the small memory card.
void setSectorModified (uint32_t sector)
 Mark sector buffer data as modified (start)
uint32_t smcGetSectCount (void)
 Get the sector count.
uint8_t smcInsertSwitch (void)
 Hardware card detect.
uint8_t smcReadCID (uint8_t *buff)
 Read the SMC's CID.
uint8_t smcReadCSD (void)
 Read the SMC's CSD.
uint8_t smcReadOCR (void)
 Read the SMC's ORC.
void smcSetFrq (uint8_t frqUse) __attribute__((always_inline))
 Set the SPI clock frequency for the small memory card.
uint8_t smcSetIdle (uint8_t mode)
 Put card to idle state.
ptfnct_t smcThreadF (void)
 The small memory card (smc) handling thread.
uint8_t writeDataBlock (uint32_t sector, const uint8_t *buff)
 Write single data block (512 byte)

Variables

struct smcThr_data_t smcState
 The (one) small memory card (SMC) state.

Define Documentation

#define SMC_LAST_R1

Last command response - first or single (R1) byte.

See also:
lastCmdResp