/* flaneth - flash and ethernet
   Copyright (C) 2007-2012 Stefan Schuermans <stefan@schuermans.info>
   Copyleft: GNU public license V2 - http://www.gnu.org/copyleft/gpl.html
   a BlinkenArea project - http://www.blinkenarea.org/ */

#ifndef INC_cf
#define INC_cf

// size of a sector in bytes
#define CF_SECTOR_SIZE (512)

// initialize
extern void CfInit(void);

// tick procedure - call every 20ms
extern void CfTick20(void);

/**
 * @brief check if CF card is present
 * @return 1 if CF card is present, 0 if not
 */
extern char CfIsPresent(void);

/**
 * @brief reset CF card
 * @return 0 if CF card could be reset, -1 if not
 */
extern char CfReset(void);

/**
 * @brief identify CF card
 * @param[out] sectors number of sectors on CF card
 * @return 0 if CF card could be identified, -1 if not
 */
extern char CfIdentify(unsigned long *sectors);

/**
 * @brief read from CF card
 * @param[in] sector number of sector to read
 * @param[out] data data read from sector
 * @return 0 if sector could be read, -1 if not
 */
extern char CfRead(unsigned long sector, unsigned char data[CF_SECTOR_SIZE]);

#endif // #ifndef INC_cf

