Revision 287
| trunk/bootloader/rs485_poll.h (revision 287) | ||
|---|---|---|
| 78 | 78 |
* @param data The byte to send |
| 79 | 79 |
*/ |
| 80 | 80 |
void rs485_send_byte(uint8_t data); |
| 81 |
|
|
| 82 |
void rs485_toggle_transmit(uint8_t state); |
|
| 81 | 83 |
#endif |
| trunk/bootloader/packet.c (revision 287) | ||
|---|---|---|
| 148 | 148 |
uint8_t i; |
| 149 | 149 |
uint8_t crc = 0; |
| 150 | 150 |
|
| 151 |
rs485_toggle_transmit(RS485_TX_ON); |
|
| 151 | 152 |
rs485_send_byte(DELIM); |
| 152 | 153 |
rs485_send_byte(addr); |
| 153 | 154 |
rs485_send_byte(SERVER); |
| ... | ... | |
| 158 | 159 |
rs485_send_byte(data[i]); |
| 159 | 160 |
} |
| 160 | 161 |
rs485_send_byte(addr ^ SERVER ^ len ^ cmd ^ crc); |
| 162 |
rs485_toggle_transmit(RS485_TX_OFF); |
|
| 161 | 163 |
} |
| 162 | 164 |
|
| trunk/bootloader/bootloader.c (revision 287) | ||
|---|---|---|
| 63 | 63 |
boot = FALSE; |
| 64 | 64 |
|
| 65 | 65 |
// Grab the address from EEPROM |
| 66 |
addr = eeprom_read_byte((void*)EEPROM_ADDR); |
|
| 66 |
addr = read_addr(); |
|
| 67 | 67 |
|
| 68 | 68 |
// Initialize the Pins |
| 69 | 69 |
DDRB = LED_GREEN | LED_YELLOW | LED_RED; // Set the LED pins as outputs |
| ... | ... | |
| 79 | 79 |
boot = TRUE; |
| 80 | 80 |
} |
| 81 | 81 |
|
| 82 |
// External override at bootup to enter bootloading mode |
|
| 82 | 83 |
if (!(BUT_PORT & (BUT_RED | BUT_BLACK))) {
|
| 83 | 84 |
boot = TRUE; |
| 84 | 85 |
} |
| trunk/bootloader/jump.S (revision 287) | ||
|---|---|---|
| 4 | 4 |
_jumptable: |
| 5 | 5 |
rjmp parse_packet |
| 6 | 6 |
rjmp send_packet |
| 7 |
rjmp read_addr |
|
| trunk/bootloader/rs485_poll.c (revision 287) | ||
|---|---|---|
| 12 | 12 |
|
| 13 | 13 |
#include <rs485_poll.h> |
| 14 | 14 |
|
| 15 |
static void rs485_toggle_transmit(uint8_t state); |
|
| 16 |
|
|
| 17 | 15 |
/** |
| 18 | 16 |
* @brief Initializes the uart |
| 19 | 17 |
* @param baud The baudrate. Use the definitions in rs485_sw.h |
| ... | ... | |
| 67 | 65 |
//Waits until current transmit is done |
| 68 | 66 |
while (!(UCSRA & _BV(UDRE))); |
| 69 | 67 |
|
| 70 |
// Enable writes and send |
|
| 71 |
rs485_toggle_transmit(RS485_TX_ON); |
|
| 68 |
// Perform the send |
|
| 72 | 69 |
UDR = data; |
| 73 | 70 |
|
| 74 | 71 |
// Waits until the transmit is done |
| 75 | 72 |
while(!(UCSRA & _BV(TXC))); |
| 76 |
rs485_toggle_transmit(RS485_TX_OFF); |
|
| 77 | 73 |
UCSRA |= _BV(TXC); |
| 78 | 74 |
|
| 79 | 75 |
return; |
| ... | ... | |
| 82 | 78 |
/** |
| 83 | 79 |
* @brief Toggles the RS485 TXEN line |
| 84 | 80 |
* |
| 85 |
* This function should not be used outside of this file |
|
| 86 |
* |
|
| 87 | 81 |
* @param state Whether to turn the pin on or off |
| 88 | 82 |
*/ |
| 89 |
static void rs485_toggle_transmit(uint8_t state) {
|
|
| 83 |
void rs485_toggle_transmit(uint8_t state) {
|
|
| 90 | 84 |
if (state == RS485_TX_ON) {
|
| 91 | 85 |
PORTD |= TX_EN; |
| 92 | 86 |
} else {
|
| trunk/bootloader/Makefile (revision 287) | ||
|---|---|---|
| 50 | 50 |
F_CPU = 8000000 |
| 51 | 51 |
|
| 52 | 52 |
# Location to place the bootloader |
| 53 |
BOOTSTART = 0x400 |
|
| 53 |
BOOTSTART = 0x3C0 |
|
| 54 | 54 |
|
| 55 | 55 |
# Location to place the jump table |
| 56 | 56 |
JUMPSTART = 0x7FC |
Also available in: Unified diff