• Main Page
  • Modules
  • Index
  • File List
  • Globals

hal/nrf24le1/hal_flash.c

Go to the documentation of this file.
00001 /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
00002  *
00003  * The information contained herein is confidential property of Nordic 
00004  * Semiconductor ASA.Terms and conditions of usage are described in detail 
00005  * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 
00006  *
00007  * Licensees are granted free, non-transferable use of the information. NO
00008  * WARRENTY of ANY KIND is provided. This heading must NOT be removed from
00009  * the file.
00010  *              
00011  * $LastChangedRevision: 133 $
00012  */ 
00013 
00018 #include "nrf24le1.h"
00019 #include "hal_flash.h"
00020 
00021 void hal_flash_page_erase(uint8_t pn)
00022 { 
00023   // Save interrupt enable state and disable interrupts:
00024   F0 = EA;
00025   EA = 0;
00026 
00027   // Enable flash write operation:
00028   WEN = 1;
00029  
00030   // Write the page address to FCR to start the page erase operation. This
00031   // operation is "self timed" when executing from the flash; the CPU will
00032   // halt until the operation is finished:
00033   FCR = pn;
00034 
00035   // When running from XDATA RAM we need to wait for the operation to finish:
00036   while(RDYN == 1)
00037     ;
00038     
00039   WEN = 0;
00040   
00041   EA = F0; // Restore interrupt enable state  
00042 }
00043 
00044 void hal_flash_byte_write(uint16_t a, uint8_t b)
00045 {
00046   static uint8_t xdata *pb;
00047     
00048   // Save interrupt enable state and disable interrupts:
00049   F0 = EA;
00050   EA = 0;
00051   
00052   // Enable flash write operation:
00053   WEN = 1;
00054   
00055   // Write the byte directly to the flash. This operation is "self timed" when
00056   // executing from the flash; the CPU will halt until the operation is
00057   // finished:
00058   pb = (uint8_t xdata *)a;
00059   *pb = b; //lint -e613 "Null pointer ok here"
00060 
00061   // When running from XDATA RAM we need to wait for the operation to finish:
00062   while(RDYN == 1)
00063     ;
00064 
00065   WEN = 0;
00066 
00067   EA = F0; // Restore interrupt enable state
00068 }
00069 
00070 void hal_flash_bytes_write(uint16_t a, const uint8_t *p, uint16_t n)
00071 {
00072   static uint8_t xdata *pb;
00073 
00074   // Save interrupt enable state and disable interrupts:
00075   F0 = EA;
00076   EA = 0;
00077 
00078   // Enable flash write operation:
00079   WEN = 1;
00080 
00081   // Write the bytes directly to the flash. This operation is
00082   // "self timed"; the CPU will halt until the operation is
00083   // finished:
00084   pb = (uint8_t xdata *)a;
00085   while(n--)
00086   {
00087     *pb++ = *p++;
00088     //
00089     // When running from XDATA RAM we need to wait for the operation to
00090     // finish:
00091     while(RDYN == 1)
00092       ;
00093   }
00094 
00095   WEN = 0;
00096 
00097   EA = F0; // Restore interrupt enable state
00098 }
00099 
00100 uint8_t hal_flash_byte_read(uint16_t a)
00101 {
00102   uint8_t xdata *pb = (uint8_t xdata *)a;
00103   return *pb;
00104 }
00105 
00106 void hal_flash_bytes_read(uint16_t a, uint8_t *p, uint16_t n)
00107 {  
00108   uint8_t xdata *pb = (uint8_t xdata *)a;
00109   while(n--)
00110   {
00111     *p = *pb;
00112     pb++;
00113     p++;
00114   }
00115 }

Generated on Fri Apr 20 2012 14:11:44 for nRFGo SDK by  doxygen 1.7.2