Program an AVR microcontroller using mbed.

Dependencies:   mbed

Revision:
2:99c56829a2a8
Parent:
1:276f6df4be7a
--- a/AVR910.h	Wed Sep 01 10:22:51 2010 +0000
+++ b/AVR910.h	Thu Sep 09 11:11:37 2010 +0000
@@ -48,12 +48,14 @@
 #define PATH_TO_BINARY "/local/AVRCODE.bin"
 
 //Commands
-#define ATMEL_VENDOR_CODE 0x1E
-#define DEVICE_LOCKED     0x00
-#define WRITE_HIGH_BYTE   0x48
-#define WRITE_LOW_BYTE    0x40
-#define READ_HIGH_BYTE    0x28
-#define READ_LOW_BYTE     0x20
+#define ATMEL_VENDOR_CODE     0x1E
+#define DEVICE_LOCKED         0x00
+#define WRITE_HIGH_BYTE       0x48
+#define WRITE_LOW_BYTE        0x40
+#define READ_HIGH_BYTE        0x28
+#define READ_LOW_BYTE         0x20
+#define WRITE_HIGH_FLASH_BYTE 0x68
+#define WRITE_LOW_FLASH_BYTE  0x60
 
 #define PAGE_SIZE         ATMEGA328P_PAGESIZE
 #define NUM_PAGES         ATMEGA328P_NUM_PAGES
@@ -91,9 +93,9 @@
      *
      * @param binary File pointer to the binary file to be loaded onto the
      *               AVR microcontroller.
-     * @param pageSize The size of one page on the device. If the device does
-     *                 not use paged memory, set this as the size of memory of
-     *                 the device.
+     * @param pageSize The size of one page on the device in words. If the
+     *                 device does not use paged memory, set this as the size
+     *                 of memory of the device in words.
      * @param numPages The number of pages on the device. If the device does
      *                 not use paged memory, set this to 1 (default).
      *
@@ -110,7 +112,7 @@
      * @param frequency Frequency of the SPI communication in hertz.
      */
     void setFrequency(int frequency);
-    
+
     /**
      * Read the vendor code of the device.
      *
@@ -161,13 +163,23 @@
     /**
      * Load a byte into the memory page buffer.
      *
-     * @param highLow Indicate whether the byte being loaded is a high or low 
+     * @param highLow Indicate whether the byte being loaded is a high or low
      *                byte.
      * @param data The data byte to load.
      */
     void loadMemoryPage(int highLow, char address, char data);
 
     /**
+     * Write a byte into the flash memory.
+     *
+     * @param highLow Indicate whether the byte being loaded is a high or low
+     *                byte.
+     * @param address The address to load the byte at.
+     * @param data The data byte to load.
+     */
+    void writeFlashMemoryByte(int highLow, int address, char data);
+
+    /**
      * Write the memory page buffer to flash memory.
      *
      * @param pageNumber The page number to write to in flash memory.
@@ -190,15 +202,15 @@
      *
      * @param numPages The number of pages written to the AVR microcontroller.
      * @param binary File pointer to the binary used.
-     * 
+     *
      * @return  0 -> No inconsistencies between binary file and AVR flash memory.
      *         -1 -> Binary file was not written correctly.
      */
     int checkMemory(int numPages, FILE* binary);
-    
+
     SPI        spi_;
     DigitalOut nReset_;
-    
+
 };
 
 #endif /* AVR910_H */