/**********************************************************************/
/*                                                                    */
/* Project Name:  flash.h                                              */
/* Last modified: 13/02/2005                                          */
/* By:            r62780                                              */
/*                                                                    */
/*                                                                    */
/**********************************************************************/
/*                                                                    */
/* Description: MC9S12DP256B_FLASH_DOONSTACK - demo                     */
/*                                                                    */
/*                                                                    */
/* Documentation: AN2720/D                                            */
/*                                                                    */
/*                                                                    */
/* This software is classified as Engineering Sample Software.        */
/*                                                                    */
/**********************************************************************/
/*                                                                    */
/* Services performed by FREESCALE in this matter are performed AS IS */
/* and without any warranty. CUSTOMER retains the final decision      */
/* relative to the total design and functionality of the end product. */ 
/* FREESCALE neither guarantees nor will be held liable by CUSTOMER   */
/* for the success of this project. FREESCALE DISCLAIMS ALL           */
/* WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY INCLUDING, BUT NOT     */
/* LIMITED TO, IMPLIED WARRANTY OF MERCHANTABILITY OR  FITNESS FOR A  */
/* PARTICULAR PURPOSE ON ANY HARDWARE, SOFTWARE ORE ADVISE SUPPLIED   */
/* TO THE PROJECT BY FREESCALE, AND OR NAY PRODUCT RESULTING FROM     */
/* FREESCALE SERVICES . IN NO EVENT SHALL FREESCALE BE LIABLE FOR     */
/* INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT. */
/*                                                                    */
/* CUSTOMER agrees to hold FREESCALE harmless against any and all     */
/* claims demands or actions by anyone on account of any damage, or   */
/* injury, whether commercial, contractual, or tortuous, rising       */
/* directly or indirectly as a result of the advise or assistance     */
/* supplied CUSTOMER in connection with product, services or goods    */
/* supplied under this Agreement.                                     */
/*                                                                    */
/**********************************************************************/
#ifndef _FLASH_H /* Prevent duplicated includes */
#define _FLASH_H

/* Specification of the MC9S12DP256 FLASH memory */
#define PROG	0x20 /* Word Program commnad */
#define ERASE	0x40 /* Sector Erase command */
#define Flash_Sector_Size 0x200 /* 512 bytes per sector */

/* Functions from flash.c */
signed char Flash_Init(unsigned long oscclk, unsigned long tbus); // [kHz,ns]
//void Flash_Init(unsigned long oscclk);
signed char Flash_Write_Word(unsigned int *far address, unsigned int data);
signed char Flash_Erase_Sector(unsigned int *far far_address);
signed char Flash_Write_Block(unsigned int *far address_source,\
unsigned int *far far_address_destination,unsigned int count);
signed char Flash_Erase_Block(unsigned int *far start_address,\
unsigned int *far end_address);
/* Error codes */
#define Flash_Odd_Access -1
#define Flash_Not_Erased -2
#define Access_Error -3
#define Protection_Error -4
#define Not_StartofSector_Error -5
#define PROGRAM_ERASE_IMPOSSIBLE -6
#endif /*_FLASH_H*/