/****************************************************************************/
/* Copyright 2015 MBARI                                                     */
/****************************************************************************/
/* Summary  : Definitions for Flash memory programming for PIC24FJ128GA406  */
/* Filename : flash_mem.h                                                   */
/* Author   : Robert Herlien (rah)                                          */
/* Project  : OASIS Mooring Replacement (OASIS5)                            */
/* Revision: 1.0                                                            */
/* Created  : 12/10/2015                                                    */
/*                                                                          */
/* MBARI provides this documentation and code "as is", with no warranty,    */
/* express or implied, of its quality or consistency. It is provided without*/
/* support and without obligation on the part of the Monterey Bay Aquarium  */
/* Research Institute to assist in its use, correction, modification, or    */
/* enhancement. This information should not be published or distributed to  */
/* third parties without specific written permission from MBARI.            */
/*                                                                          */
/****************************************************************************/
/* Modification History:                                                    */
/* 12dec2015  rah created                                                   */
/****************************************************************************/

#ifndef FLASH_MEM_H
#define FLASH_MEM_H

#include <xc.h>

#define FLASH_MEM_DEBUG 0

#define PARAM_PAGE      0x1000
#define MAX_PAGE_BYTES  0x200

/* Constants for PIC24FJ128GA406  */
#define WORDS_PER_ROW   64

#define PM_PAGE_ERASE   0x4003          /* NVM page erase opcode */
#define PM_ROW_WRITE    0x4002          /* NVM row write opcode  */
#define PM_DWORD_WRITE   0x4001         /* NVM dword write opcode */

int memRead(char* buff, int cnt);
int memWrite(char* buff, int cnt);
void memErase();

#endif
