Program an AVR microcontroller using mbed.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

AVR910 Class Reference

AVR910 Class Reference

AVR910 ISP. More...

#include <AVR910.h>

Public Member Functions

 AVR910 (PinName mosi, PinName miso, PinName sclk, PinName nReset)
 Constructor.
int program (FILE *binary, int pageSize, int numPages=1)
 Program the AVR microcontroller connected to the mbed.
void setFrequency (int frequency)
 Set the frequency of the SPI communication.
int readVendorCode (void)
 Read the vendor code of the device.
int readPartFamilyAndFlashSize (void)
 Read the part family and flash size of the device.
int readPartNumber (void)
 Read the part number.

Detailed Description

AVR910 ISP.

Definition at line 70 of file AVR910.h.


Constructor & Destructor Documentation

AVR910 ( PinName  mosi,
PinName  miso,
PinName  sclk,
PinName  nReset 
)

Constructor.

Parameters:
mosimbed pin for MOSI SPI line.
misombed pin for MISO SPI line.
sclkmbed pin for SCLK SPI line.
nResetmbed pin for not reset line on the ISP interface.

Sends an enable programming command, allowing device registers to be read and commands sent.

Definition at line 43 of file AVR910.cpp.


Member Function Documentation

int program ( FILE *  binary,
int  pageSize,
int  numPages = 1 
)

Program the AVR microcontroller connected to the mbed.

Sends a chip erase command followed by writing the binary to the AVR page buffer and writing the page buffer to flash memory whenever it is full.

Parameters:
binaryFile pointer to the binary file to be loaded onto the AVR microcontroller.
pageSizeThe 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.
numPagesThe number of pages on the device. If the device does not use paged memory, set this to 1 (default).
Returns:
0 => AVR microcontroller programmed successfully. -1 => Problem during programming.

Definition at line 87 of file AVR910.cpp.

int readPartFamilyAndFlashSize ( void   )

Read the part family and flash size of the device.

Returns:
Code indicating the family of AVR microcontrollers the device comes from and how much flash memory it contains. 0xFF -> Device code erased or target missing. 0x01 -> Device is locked.

Definition at line 230 of file AVR910.cpp.

int readPartNumber ( void   )

Read the part number.

Returns:
Code identifying the part number. 0xFF -> Device code erased or target missing. 0x02 -> Device is locked.

Definition at line 245 of file AVR910.cpp.

int readVendorCode ( void   )

Read the vendor code of the device.

Returns:
The vendor code - should be 0x1E for Atmel. 0x00 -> Device is locked.

Definition at line 215 of file AVR910.cpp.

void setFrequency ( int  frequency )

Set the frequency of the SPI communication.

(Wrapper for SPI::frequency)

Parameters:
frequencyFrequency of the SPI communication in hertz.

Definition at line 171 of file AVR910.cpp.