Fixed up file indent, comments, and eol-type.
This commit is contained in:
@@ -325,7 +325,8 @@ static void address_parse(BACNET_ADDRESS * dst,
|
|||||||
dst->mac_len = 6;
|
dst->mac_len = 6;
|
||||||
for (index = 0; index < 4; index++) {
|
for (index = 0; index < 4; index++) {
|
||||||
dst->mac[index] = mac[index];
|
dst->mac[index] = mac[index];
|
||||||
} encode_unsigned16(&dst->mac[4],
|
}
|
||||||
|
encode_unsigned16(&dst->mac[4],
|
||||||
port);
|
port);
|
||||||
} else {
|
} else {
|
||||||
count =
|
count =
|
||||||
|
|||||||
@@ -680,8 +680,7 @@ int Device_Encode_Property_APDU(
|
|||||||
case PROP_LOCATION:
|
case PROP_LOCATION:
|
||||||
characterstring_init_ansi(&char_string, Location);
|
characterstring_init_ansi(&char_string, Location);
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_character_string(&apdu[0],
|
encode_application_character_string(&apdu[0], &char_string);
|
||||||
&char_string);
|
|
||||||
break;
|
break;
|
||||||
/* FIXME: if you support time */
|
/* FIXME: if you support time */
|
||||||
case PROP_LOCAL_TIME:
|
case PROP_LOCAL_TIME:
|
||||||
|
|||||||
@@ -230,8 +230,7 @@ void cleanup(void) {
|
|||||||
old_rpm_property = rpm_property;
|
old_rpm_property = rpm_property;
|
||||||
rpm_property = rpm_property->next;
|
rpm_property = rpm_property->next;
|
||||||
free(old_rpm_property);
|
free(old_rpm_property);
|
||||||
}
|
} old_rpm_object = rpm_object;
|
||||||
old_rpm_object = rpm_object;
|
|
||||||
rpm_object = rpm_object->next;
|
rpm_object = rpm_object->next;
|
||||||
free(old_rpm_object);
|
free(old_rpm_object);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,8 +212,8 @@ int main(int argc, char *argv[]) {
|
|||||||
filename_remove_path(argv[0]), filename_remove_path(argv[0]));
|
filename_remove_path(argv[0]), filename_remove_path(argv[0]));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* decode the command line parameters */
|
/* decode the command line parameters */ cov_data.
|
||||||
cov_data.subscriberProcessIdentifier = strtol(argv[1], NULL, 0);
|
subscriberProcessIdentifier = strtol(argv[1], NULL, 0);
|
||||||
cov_data.initiatingDeviceIdentifier = strtol(argv[2], NULL, 0);
|
cov_data.initiatingDeviceIdentifier = strtol(argv[2], NULL, 0);
|
||||||
cov_data.monitoredObjectIdentifier.type = strtol(argv[3], NULL, 0);
|
cov_data.monitoredObjectIdentifier.type = strtol(argv[3], NULL, 0);
|
||||||
cov_data.monitoredObjectIdentifier.instance = strtol(argv[4], NULL, 0);
|
cov_data.monitoredObjectIdentifier.instance = strtol(argv[4], NULL, 0);
|
||||||
|
|||||||
@@ -35,7 +35,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
void Binary_Output_Init(void);
|
void Binary_Output_Init(
|
||||||
|
void);
|
||||||
|
|
||||||
void Binary_Output_Property_Lists(
|
void Binary_Output_Property_Lists(
|
||||||
const int **pRequired,
|
const int **pRequired,
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
void Device_Init(void);
|
void Device_Init(
|
||||||
|
void);
|
||||||
|
|
||||||
void Device_Property_Lists(
|
void Device_Property_Lists(
|
||||||
const int **pRequired,
|
const int **pRequired,
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ void stack_init(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned stack_size(void)
|
unsigned stack_size(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
return (&__stack) - (&_end);
|
return (&__stack) - (&_end);
|
||||||
@@ -66,7 +67,8 @@ unsigned stack_size(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t stack_byte(unsigned offset)
|
uint8_t stack_byte(
|
||||||
|
unsigned offset)
|
||||||
{
|
{
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
return *(&_end + offset);
|
return *(&_end + offset);
|
||||||
@@ -76,7 +78,8 @@ uint8_t stack_byte(unsigned offset)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned stack_unused(void)
|
unsigned stack_unused(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
|
|||||||
@@ -33,16 +33,19 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* C stack checking */
|
/* C stack checking */
|
||||||
void stack_init(void);
|
void stack_init(
|
||||||
|
void);
|
||||||
|
|
||||||
unsigned stack_size(void);
|
unsigned stack_size(
|
||||||
|
void);
|
||||||
|
|
||||||
uint8_t stack_byte(unsigned offset);
|
uint8_t stack_byte(
|
||||||
|
unsigned offset);
|
||||||
|
|
||||||
unsigned stack_unused(void);
|
unsigned stack_unused(
|
||||||
|
void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -45,8 +45,7 @@
|
|||||||
/* the Relinquish Default value */
|
/* the Relinquish Default value */
|
||||||
#define RELINQUISH_DEFAULT BINARY_INACTIVE
|
#define RELINQUISH_DEFAULT BINARY_INACTIVE
|
||||||
/* Here is our Priority Array.*/
|
/* Here is our Priority Array.*/
|
||||||
static uint8_t
|
static uint8_t Binary_Output_Level[MAX_BINARY_OUTPUTS][BACNET_MAX_PRIORITY];
|
||||||
Binary_Output_Level[MAX_BINARY_OUTPUTS][BACNET_MAX_PRIORITY];
|
|
||||||
/* Writable out-of-service allows others to play with our Present Value */
|
/* Writable out-of-service allows others to play with our Present Value */
|
||||||
/* without changing the physical output */
|
/* without changing the physical output */
|
||||||
static uint8_t Out_Of_Service[MAX_BINARY_OUTPUTS];
|
static uint8_t Out_Of_Service[MAX_BINARY_OUTPUTS];
|
||||||
@@ -102,11 +101,9 @@ void Binary_Output_Level_Set(
|
|||||||
if (object_index < MAX_BINARY_OUTPUTS) {
|
if (object_index < MAX_BINARY_OUTPUTS) {
|
||||||
if (priority < BACNET_MAX_PRIORITY) {
|
if (priority < BACNET_MAX_PRIORITY) {
|
||||||
Binary_Output_Level[object_index][priority] = (uint8_t) level;
|
Binary_Output_Level[object_index][priority] = (uint8_t) level;
|
||||||
seeprom_bytes_write(
|
seeprom_bytes_write(NV_SEEPROM_BINARY_OUTPUT(object_index,
|
||||||
NV_SEEPROM_BINARY_OUTPUT(object_index,
|
|
||||||
NV_SEEPROM_BO_PRIORITY_ARRAY_1 + priority),
|
NV_SEEPROM_BO_PRIORITY_ARRAY_1 + priority),
|
||||||
&Binary_Output_Level[object_index][priority],
|
&Binary_Output_Level[object_index][priority], 1);
|
||||||
1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,11 +115,8 @@ void Binary_Output_Polarity_Set(
|
|||||||
if (object_index < MAX_BINARY_OUTPUTS) {
|
if (object_index < MAX_BINARY_OUTPUTS) {
|
||||||
if (polarity < MAX_POLARITY) {
|
if (polarity < MAX_POLARITY) {
|
||||||
Polarity[object_index] = POLARITY_NORMAL;
|
Polarity[object_index] = POLARITY_NORMAL;
|
||||||
seeprom_bytes_write(
|
seeprom_bytes_write(NV_SEEPROM_BINARY_OUTPUT(object_index,
|
||||||
NV_SEEPROM_BINARY_OUTPUT(object_index,
|
NV_SEEPROM_BO_POLARITY), &Polarity[object_index], 1);
|
||||||
NV_SEEPROM_BO_POLARITY),
|
|
||||||
&Polarity[object_index],
|
|
||||||
1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,10 +127,8 @@ void Binary_Output_Out_Of_Service_Set(
|
|||||||
{
|
{
|
||||||
if (object_index < MAX_BINARY_OUTPUTS) {
|
if (object_index < MAX_BINARY_OUTPUTS) {
|
||||||
Out_Of_Service[object_index] = flag;
|
Out_Of_Service[object_index] = flag;
|
||||||
seeprom_bytes_write(
|
seeprom_bytes_write(NV_SEEPROM_BINARY_OUTPUT(object_index,
|
||||||
NV_SEEPROM_BINARY_OUTPUT(object_index,
|
NV_SEEPROM_BO_OUT_OF_SERVICE), &Out_Of_Service[object_index],
|
||||||
NV_SEEPROM_BO_OUT_OF_SERVICE),
|
|
||||||
&Out_Of_Service[object_index],
|
|
||||||
1);
|
1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -312,7 +304,8 @@ int Binary_Output_Encode_Property_APDU(
|
|||||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||||
break;
|
break;
|
||||||
case PROP_POLARITY:
|
case PROP_POLARITY:
|
||||||
apdu_len = encode_application_enumerated(&apdu[0],
|
apdu_len =
|
||||||
|
encode_application_enumerated(&apdu[0],
|
||||||
Polarity[object_index]);
|
Polarity[object_index]);
|
||||||
break;
|
break;
|
||||||
case PROP_PRIORITY_ARRAY:
|
case PROP_PRIORITY_ARRAY:
|
||||||
@@ -506,26 +499,20 @@ void Binary_Output_Init(
|
|||||||
|
|
||||||
/* initialize all the analog output priority arrays to NULL */
|
/* initialize all the analog output priority arrays to NULL */
|
||||||
for (i = 0; i < MAX_BINARY_OUTPUTS; i++) {
|
for (i = 0; i < MAX_BINARY_OUTPUTS; i++) {
|
||||||
seeprom_bytes_read(
|
seeprom_bytes_read(NV_SEEPROM_BINARY_OUTPUT(i, NV_SEEPROM_BO_POLARITY),
|
||||||
NV_SEEPROM_BINARY_OUTPUT(i,NV_SEEPROM_BO_POLARITY),
|
&Polarity[i], 1);
|
||||||
&Polarity[i],
|
|
||||||
1);
|
|
||||||
if (Polarity[i] >= MAX_POLARITY) {
|
if (Polarity[i] >= MAX_POLARITY) {
|
||||||
Binary_Output_Polarity_Set(i, POLARITY_NORMAL);
|
Binary_Output_Polarity_Set(i, POLARITY_NORMAL);
|
||||||
}
|
}
|
||||||
seeprom_bytes_read(
|
seeprom_bytes_read(NV_SEEPROM_BINARY_OUTPUT(i,
|
||||||
NV_SEEPROM_BINARY_OUTPUT(i,NV_SEEPROM_BO_OUT_OF_SERVICE),
|
NV_SEEPROM_BO_OUT_OF_SERVICE), &Out_Of_Service[i], 1);
|
||||||
&Out_Of_Service[i],
|
|
||||||
1);
|
|
||||||
if (Out_Of_Service[i] > 1) {
|
if (Out_Of_Service[i] > 1) {
|
||||||
Binary_Output_Out_Of_Service_Set(i, false);
|
Binary_Output_Out_Of_Service_Set(i, false);
|
||||||
}
|
}
|
||||||
for (j = 0; j < BACNET_MAX_PRIORITY; j++) {
|
for (j = 0; j < BACNET_MAX_PRIORITY; j++) {
|
||||||
seeprom_bytes_read(
|
seeprom_bytes_read(NV_SEEPROM_BINARY_OUTPUT(i,
|
||||||
NV_SEEPROM_BINARY_OUTPUT(i,
|
|
||||||
NV_SEEPROM_BO_PRIORITY_ARRAY_1 + j),
|
NV_SEEPROM_BO_PRIORITY_ARRAY_1 + j),
|
||||||
&Binary_Output_Level[i][j],
|
&Binary_Output_Level[i][j], 1);
|
||||||
1);
|
|
||||||
}
|
}
|
||||||
Binary_Output_Sync(i);
|
Binary_Output_Sync(i);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* definitions generated by preprocessor, copy into defines.h */
|
/* definitions generated by preprocessor, copy into defines.h */
|
||||||
#ifndef PPINC
|
#ifndef PPINC
|
||||||
#define _ATMEGA644P // device select: _ATMEGAxxxx
|
#define _ATMEGA644P /* device select: _ATMEGAxxxx */
|
||||||
#define _B2048 // boot size select: _Bxxxx (words), powers of two only
|
#define _B2048 /* boot size select: _Bxxxx (words), powers of two only */
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#include "iom644.h"
|
#include "iom644.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
#define SPMCR_REG SPMCSR
|
#define SPMCR_REG SPMCSR
|
||||||
#define PAGESIZE 256
|
#define PAGESIZE 256
|
||||||
#define APP_END 61440
|
#define APP_END 61440
|
||||||
//#define LARGE_MEMORY
|
/*#define LARGE_MEMORY */
|
||||||
|
|
||||||
/* definitions for device recognition */
|
/* definitions for device recognition */
|
||||||
#define PARTCODE 0
|
#define PARTCODE 0
|
||||||
|
|||||||
@@ -31,11 +31,11 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Uncomment the following to save code space */
|
/* Uncomment the following to save code space */
|
||||||
//#define REMOVE_AVRPROG_SUPPORT
|
/*#define REMOVE_AVRPROG_SUPPORT */
|
||||||
//#define REMOVE_FUSE_AND_LOCK_BIT_SUPPORT
|
/*#define REMOVE_FUSE_AND_LOCK_BIT_SUPPORT */
|
||||||
//#define REMOVE_BLOCK_SUPPORT
|
/*#define REMOVE_BLOCK_SUPPORT */
|
||||||
//#define REMOVE_EEPROM_BYTE_SUPPORT
|
/*#define REMOVE_EEPROM_BYTE_SUPPORT */
|
||||||
//#define REMOVE_FLASH_BYTE_SUPPORT
|
/*#define REMOVE_FLASH_BYTE_SUPPORT */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GCC doesn't optimize long int arithmetics very clever. As the
|
* GCC doesn't optimize long int arithmetics very clever. As the
|
||||||
@@ -52,8 +52,14 @@
|
|||||||
#endif /* LARGE_MEMORY */
|
#endif /* LARGE_MEMORY */
|
||||||
|
|
||||||
#ifndef REMOVE_BLOCK_SUPPORT
|
#ifndef REMOVE_BLOCK_SUPPORT
|
||||||
unsigned char BlockLoad(unsigned int size, unsigned char mem, ADDR_T *address);
|
unsigned char BlockLoad(
|
||||||
void BlockRead(unsigned int size, unsigned char mem, ADDR_T *address);
|
unsigned int size,
|
||||||
|
unsigned char mem,
|
||||||
|
ADDR_T * address);
|
||||||
|
void BlockRead(
|
||||||
|
unsigned int size,
|
||||||
|
unsigned char mem,
|
||||||
|
ADDR_T * address);
|
||||||
|
|
||||||
/* BLOCKSIZE should be chosen so that the following holds: BLOCKSIZE*n = PAGESIZE, where n=1,2,3... */
|
/* BLOCKSIZE should be chosen so that the following holds: BLOCKSIZE*n = PAGESIZE, where n=1,2,3... */
|
||||||
#define BLOCKSIZE PAGESIZE
|
#define BLOCKSIZE PAGESIZE
|
||||||
@@ -61,11 +67,12 @@ void BlockRead(unsigned int size, unsigned char mem, ADDR_T *address);
|
|||||||
#endif /* REMOVE_BLOCK_SUPPORT */
|
#endif /* REMOVE_BLOCK_SUPPORT */
|
||||||
|
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
__C_task void main(void)
|
__C_task void main(
|
||||||
|
void)
|
||||||
#else /* ! __ICCAVR__ */
|
#else /* ! __ICCAVR__ */
|
||||||
int main(void)
|
int main(
|
||||||
|
void)
|
||||||
#endif /* __ICCAVR__ */
|
#endif /* __ICCAVR__ */
|
||||||
|
|
||||||
{
|
{
|
||||||
ADDR_T address;
|
ADDR_T address;
|
||||||
unsigned int temp_int;
|
unsigned int temp_int;
|
||||||
@@ -73,214 +80,192 @@ int main(void)
|
|||||||
|
|
||||||
|
|
||||||
/* Initialization */
|
/* Initialization */
|
||||||
void (*funcptr)( void ) = 0x0000; // Set up function pointer to RESET vector.
|
void (
|
||||||
PROGPORT |= (1<<PROG_NO); // Enable pull-up on PROG_NO line on PROGPORT.
|
*funcptr) (
|
||||||
initbootuart(); // Initialize UART.
|
void) = 0x0000; /* Set up function pointer to RESET vector. */
|
||||||
|
PROGPORT |= (1 << PROG_NO); /* Enable pull-up on PROG_NO line on PROGPORT. */
|
||||||
|
initbootuart(); /* Initialize UART. */
|
||||||
|
|
||||||
|
|
||||||
/* Branch to bootloader or application code? */
|
/* Branch to bootloader or application code? */
|
||||||
if( !(PROGPIN & (1<<PROG_NO)) ) // If PROGPIN is pulled low, enter programmingmode.
|
if (!(PROGPIN & (1 << PROG_NO))) { /* If PROGPIN is pulled low, enter programmingmode. */
|
||||||
{
|
|
||||||
/* Main loop */
|
/* Main loop */
|
||||||
for(;;)
|
for (;;) {
|
||||||
{
|
val = recchar(); /* Wait for command character. */
|
||||||
val=recchar(); // Wait for command character.
|
|
||||||
|
|
||||||
// Check autoincrement status.
|
/* Check autoincrement status. */
|
||||||
if(val=='a')
|
if (val == 'a') {
|
||||||
{
|
sendchar('Y'); /* Yes, we do autoincrement. */
|
||||||
sendchar('Y'); // Yes, we do autoincrement.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set address.
|
/* Set address. */
|
||||||
else if(val=='A') // Set address...
|
else if (val == 'A') { /* Set address... *//* NOTE: Flash addresses are given in words, not bytes. */
|
||||||
{ // NOTE: Flash addresses are given in words, not bytes.
|
address = (recchar() << 8) | recchar(); /* Read address high and low byte. */
|
||||||
address=(recchar()<<8) | recchar(); // Read address high and low byte.
|
sendchar('\r'); /* Send OK back. */
|
||||||
sendchar('\r'); // Send OK back.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Chip erase.
|
/* Chip erase. */
|
||||||
else if(val=='e')
|
else if (val == 'e') {
|
||||||
{
|
for (address = 0; address < APP_END; address += PAGESIZE) { /* NOTE: Here we use address as a byte-address, not word-address, for convenience. */
|
||||||
for(address = 0; address < APP_END;address += PAGESIZE)
|
|
||||||
{ // NOTE: Here we use address as a byte-address, not word-address, for convenience.
|
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_suppress=Pe1053 // Suppress warning for conversion from long-type address to flash ptr.
|
#pragma diag_suppress=Pe1053 /* Suppress warning for conversion from long-type address to flash ptr. */
|
||||||
#endif
|
#endif
|
||||||
_PAGE_ERASE(address);
|
_PAGE_ERASE(address);
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_default=Pe1053 // Back to default.
|
#pragma diag_default=Pe1053 /* Back to default. */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
sendchar('\r'); // Send OK back.
|
sendchar('\r'); /* Send OK back. */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef REMOVE_BLOCK_SUPPORT
|
#ifndef REMOVE_BLOCK_SUPPORT
|
||||||
// Check block load support.
|
/* Check block load support. */
|
||||||
else if(val=='b')
|
else if (val == 'b') {
|
||||||
{
|
sendchar('Y'); /* Report block load supported. */
|
||||||
sendchar('Y'); // Report block load supported.
|
sendchar((BLOCKSIZE >> 8) & 0xFF); /* MSB first. */
|
||||||
sendchar((BLOCKSIZE>>8) & 0xFF); // MSB first.
|
sendchar(BLOCKSIZE & 0xFF); /* Report BLOCKSIZE (bytes). */
|
||||||
sendchar(BLOCKSIZE&0xFF); // Report BLOCKSIZE (bytes).
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Start block load.
|
/* Start block load. */
|
||||||
else if(val=='B')
|
else if (val == 'B') {
|
||||||
{
|
temp_int = (recchar() << 8) | recchar(); /* Get block size. */
|
||||||
temp_int = (recchar()<<8) | recchar(); // Get block size.
|
val = recchar(); /* Get memtype. */
|
||||||
val = recchar(); // Get memtype.
|
sendchar(BlockLoad(temp_int, val, &address)); /* Block load. */
|
||||||
sendchar( BlockLoad(temp_int,val,&address) ); // Block load.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Start block read.
|
/* Start block read. */
|
||||||
else if(val=='g')
|
else if (val == 'g') {
|
||||||
{
|
temp_int = (recchar() << 8) | recchar(); /* Get block size. */
|
||||||
temp_int = (recchar()<<8) | recchar(); // Get block size.
|
val = recchar(); /* Get memtype */
|
||||||
val = recchar(); // Get memtype
|
BlockRead(temp_int, val, &address); /* Block read */
|
||||||
BlockRead(temp_int,val,&address); // Block read
|
|
||||||
}
|
}
|
||||||
#endif /* REMOVE_BLOCK_SUPPORT */
|
#endif /* REMOVE_BLOCK_SUPPORT */
|
||||||
|
|
||||||
#ifndef REMOVE_FLASH_BYTE_SUPPORT
|
#ifndef REMOVE_FLASH_BYTE_SUPPORT
|
||||||
// Read program memory.
|
/* Read program memory. */
|
||||||
else if(val=='R')
|
else if (val == 'R') {
|
||||||
{
|
/* Send high byte, then low byte of flash word. */
|
||||||
// Send high byte, then low byte of flash word.
|
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
_ENABLE_RWW_SECTION();
|
_ENABLE_RWW_SECTION();
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_suppress=Pe1053 // Suppress warning for conversion from long-type address to flash ptr.
|
#pragma diag_suppress=Pe1053 /* Suppress warning for conversion from long-type address to flash ptr. */
|
||||||
#endif
|
#endif
|
||||||
sendchar(_LOAD_PROGRAM_MEMORY((address << 1) + 1));
|
sendchar(_LOAD_PROGRAM_MEMORY((address << 1) + 1));
|
||||||
sendchar(_LOAD_PROGRAM_MEMORY((address << 1) + 0));
|
sendchar(_LOAD_PROGRAM_MEMORY((address << 1) + 0));
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_default=Pe1053 // Back to default.
|
#pragma diag_default=Pe1053 /* Back to default. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
address++; // Auto-advance to next Flash word.
|
address++; /* Auto-advance to next Flash word. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Write program memory, low byte.
|
/* Write program memory, low byte. */
|
||||||
else if(val=='c')
|
else if (val == 'c') { /* NOTE: Always use this command before sending high byte. */
|
||||||
{ // NOTE: Always use this command before sending high byte.
|
temp_int = recchar(); /* Get low byte for later _FILL_TEMP_WORD. */
|
||||||
temp_int=recchar(); // Get low byte for later _FILL_TEMP_WORD.
|
sendchar('\r'); /* Send OK back. */
|
||||||
sendchar('\r'); // Send OK back.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Write program memory, high byte.
|
/* Write program memory, high byte. */
|
||||||
else if(val=='C')
|
else if (val == 'C') {
|
||||||
{
|
temp_int |= (recchar() << 8); /* Get and insert high byte. */
|
||||||
temp_int |= (recchar()<<8); // Get and insert high byte.
|
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_suppress=Pe1053 // Suppress warning for conversion from long-type address to flash ptr.
|
#pragma diag_suppress=Pe1053 /* Suppress warning for conversion from long-type address to flash ptr. */
|
||||||
#endif
|
#endif
|
||||||
_FILL_TEMP_WORD( (address << 1), temp_int ); // Convert word-address to byte-address and fill.
|
_FILL_TEMP_WORD((address << 1), temp_int); /* Convert word-address to byte-address and fill. */
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_default=Pe1053 // Back to default.
|
#pragma diag_default=Pe1053 /* Back to default. */
|
||||||
#endif
|
#endif
|
||||||
address++; // Auto-advance to next Flash word.
|
address++; /* Auto-advance to next Flash word. */
|
||||||
sendchar('\r'); // Send OK back.
|
sendchar('\r'); /* Send OK back. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Write page.
|
/* Write page. */
|
||||||
else if(val== 'm')
|
else if (val == 'm') {
|
||||||
{
|
if (address >= (APP_END >> 1)) { /* Protect bootloader area. */
|
||||||
if( address >= (APP_END>>1) ) // Protect bootloader area.
|
|
||||||
{
|
|
||||||
sendchar('?');
|
sendchar('?');
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_suppress=Pe1053 // Suppress warning for conversion from long-type address to flash ptr.
|
#pragma diag_suppress=Pe1053 /* Suppress warning for conversion from long-type address to flash ptr. */
|
||||||
#endif
|
#endif
|
||||||
_PAGE_WRITE( address << 1 ); // Convert word-address to byte-address and write.
|
_PAGE_WRITE(address << 1); /* Convert word-address to byte-address and write. */
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_default=Pe1053 // Back to default.
|
#pragma diag_default=Pe1053 /* Back to default. */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
sendchar('\r'); // Send OK back.
|
sendchar('\r'); /* Send OK back. */
|
||||||
}
|
}
|
||||||
#endif /* REMOVE_FLASH_BYTE_SUPPORT */
|
#endif /* REMOVE_FLASH_BYTE_SUPPORT */
|
||||||
|
|
||||||
#ifndef REMOVE_EEPROM_BYTE_SUPPORT
|
#ifndef REMOVE_EEPROM_BYTE_SUPPORT
|
||||||
// Write EEPROM memory.
|
/* Write EEPROM memory. */
|
||||||
else if (val == 'D')
|
else if (val == 'D') {
|
||||||
{
|
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
EEARL = address; // Setup EEPROM address.
|
EEARL = address; /* Setup EEPROM address. */
|
||||||
EEARH = (address >> 8);
|
EEARH = (address >> 8);
|
||||||
EEDR = recchar(); // Get byte.
|
EEDR = recchar(); /* Get byte. */
|
||||||
EECR |= (1<<EEMWE); // Write byte.
|
EECR |= (1 << EEMWE); /* Write byte. */
|
||||||
EECR |= (1 << EEWE);
|
EECR |= (1 << EEWE);
|
||||||
while (EECR & (1<<EEWE)) // Wait for write operation to finish.
|
while (EECR & (1 << EEWE)) /* Wait for write operation to finish. */
|
||||||
;
|
;
|
||||||
|
|
||||||
address++; // Auto-advance to next EEPROM byte.
|
address++; /* Auto-advance to next EEPROM byte. */
|
||||||
sendchar('\r');// Send OK back.
|
sendchar('\r'); /* Send OK back. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read EEPROM memory.
|
/* Read EEPROM memory. */
|
||||||
else if (val == 'd')
|
else if (val == 'd') {
|
||||||
{
|
EEARL = address; /* Setup EEPROM address. */
|
||||||
EEARL = address; // Setup EEPROM address.
|
|
||||||
EEARH = (address >> 8);
|
EEARH = (address >> 8);
|
||||||
EECR |= (1<<EERE); // Read byte...
|
EECR |= (1 << EERE); /* Read byte... */
|
||||||
sendchar(EEDR); // ...and send it back.
|
sendchar(EEDR); /* ...and send it back. */
|
||||||
address++; // Auto-advance to next EEPROM byte.
|
address++; /* Auto-advance to next EEPROM byte. */
|
||||||
}
|
}
|
||||||
#endif /* REMOVE_EEPROM_BYTE_SUPPORT */
|
#endif /* REMOVE_EEPROM_BYTE_SUPPORT */
|
||||||
|
|
||||||
#ifndef REMOVE_FUSE_AND_LOCK_BIT_SUPPORT
|
#ifndef REMOVE_FUSE_AND_LOCK_BIT_SUPPORT
|
||||||
// Write lockbits.
|
/* Write lockbits. */
|
||||||
else if(val=='l')
|
else if (val == 'l') {
|
||||||
{
|
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
_SET_LOCK_BITS( recchar() ); // Read and set lock bits.
|
_SET_LOCK_BITS(recchar()); /* Read and set lock bits. */
|
||||||
sendchar('\r'); // Send OK back.
|
sendchar('\r'); /* Send OK back. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(_GET_LOCK_BITS)
|
#if defined(_GET_LOCK_BITS)
|
||||||
// Read lock bits.
|
/* Read lock bits. */
|
||||||
else if(val=='r')
|
else if (val == 'r') {
|
||||||
{
|
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
sendchar(_GET_LOCK_BITS());
|
sendchar(_GET_LOCK_BITS());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read fuse bits.
|
/* Read fuse bits. */
|
||||||
else if(val=='F')
|
else if (val == 'F') {
|
||||||
{
|
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
sendchar(_GET_LOW_FUSES());
|
sendchar(_GET_LOW_FUSES());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read high fuse bits.
|
/* Read high fuse bits. */
|
||||||
else if(val=='N')
|
else if (val == 'N') {
|
||||||
{
|
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
sendchar(_GET_HIGH_FUSES());
|
sendchar(_GET_HIGH_FUSES());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read extended fuse bits.
|
/* Read extended fuse bits. */
|
||||||
else if(val=='Q')
|
else if (val == 'Q') {
|
||||||
{
|
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
sendchar(_GET_EXTENDED_FUSES());
|
sendchar(_GET_EXTENDED_FUSES());
|
||||||
}
|
}
|
||||||
@@ -288,53 +273,47 @@ int main(void)
|
|||||||
#endif /* REMOVE_FUSE_AND_LOCK_BIT_SUPPORT */
|
#endif /* REMOVE_FUSE_AND_LOCK_BIT_SUPPORT */
|
||||||
|
|
||||||
#ifndef REMOVE_AVRPROG_SUPPORT
|
#ifndef REMOVE_AVRPROG_SUPPORT
|
||||||
// Enter and leave programming mode.
|
/* Enter and leave programming mode. */
|
||||||
else if((val=='P')||(val=='L'))
|
else if ((val == 'P') || (val == 'L')) {
|
||||||
{
|
sendchar('\r'); /* Nothing special to do, just answer OK. */
|
||||||
sendchar('\r'); // Nothing special to do, just answer OK.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Exit bootloader.
|
/* Exit bootloader. */
|
||||||
else if(val=='E')
|
else if (val == 'E') {
|
||||||
{
|
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
_ENABLE_RWW_SECTION();
|
_ENABLE_RWW_SECTION();
|
||||||
sendchar('\r');
|
sendchar('\r');
|
||||||
funcptr(); // Jump to Reset vector 0x0000 in Application Section.
|
funcptr(); /* Jump to Reset vector 0x0000 in Application Section. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get programmer type.
|
/* Get programmer type. */
|
||||||
else if (val=='p')
|
else if (val == 'p') {
|
||||||
{
|
sendchar('S'); /* Answer 'SERIAL'. */
|
||||||
sendchar('S'); // Answer 'SERIAL'.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return supported device codes.
|
/* Return supported device codes. */
|
||||||
else if(val=='t')
|
else if (val == 't') {
|
||||||
{
|
|
||||||
#if PARTCODE+0 > 0
|
#if PARTCODE+0 > 0
|
||||||
sendchar( PARTCODE ); // Supports only this device, of course.
|
sendchar(PARTCODE); /* Supports only this device, of course. */
|
||||||
#endif /* PARTCODE */
|
#endif /* PARTCODE */
|
||||||
sendchar( 0 ); // Send list terminator.
|
sendchar(0); /* Send list terminator. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set LED, clear LED and set device type.
|
/* Set LED, clear LED and set device type. */
|
||||||
else if((val=='x')||(val=='y')||(val=='T'))
|
else if ((val == 'x') || (val == 'y') || (val == 'T')) {
|
||||||
{
|
recchar(); /* Ignore the command and it's parameter. */
|
||||||
recchar(); // Ignore the command and it's parameter.
|
sendchar('\r'); /* Send OK back. */
|
||||||
sendchar('\r'); // Send OK back.
|
|
||||||
}
|
}
|
||||||
#endif /* REMOVE_AVRPROG_SUPPORT */
|
#endif /* REMOVE_AVRPROG_SUPPORT */
|
||||||
|
|
||||||
// Return programmer identifier.
|
/* Return programmer identifier. */
|
||||||
else if(val=='S')
|
else if (val == 'S') {
|
||||||
{
|
sendchar('A'); /* Return 'AVRBOOT'. */
|
||||||
sendchar('A'); // Return 'AVRBOOT'.
|
sendchar('V'); /* Software identifier (aka programmer signature) is always 7 characters. */
|
||||||
sendchar('V'); // Software identifier (aka programmer signature) is always 7 characters.
|
|
||||||
sendchar('R');
|
sendchar('R');
|
||||||
sendchar('B');
|
sendchar('B');
|
||||||
sendchar('O');
|
sendchar('O');
|
||||||
@@ -343,151 +322,143 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return software version.
|
/* Return software version. */
|
||||||
else if(val=='V')
|
else if (val == 'V') {
|
||||||
{
|
|
||||||
sendchar('1');
|
sendchar('1');
|
||||||
sendchar('5');
|
sendchar('5');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return signature bytes.
|
/* Return signature bytes. */
|
||||||
else if(val=='s')
|
else if (val == 's') {
|
||||||
{
|
|
||||||
sendchar(SIGNATURE_BYTE_3);
|
sendchar(SIGNATURE_BYTE_3);
|
||||||
sendchar(SIGNATURE_BYTE_2);
|
sendchar(SIGNATURE_BYTE_2);
|
||||||
sendchar(SIGNATURE_BYTE_1);
|
sendchar(SIGNATURE_BYTE_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// The last command to accept is ESC (synchronization).
|
/* The last command to accept is ESC (synchronization). */
|
||||||
else if(val!=0x1b) // If not ESC, then it is unrecognized...
|
else if (val != 0x1b) { /* If not ESC, then it is unrecognized... */
|
||||||
{
|
|
||||||
sendchar('?');
|
sendchar('?');
|
||||||
}
|
}
|
||||||
} // end: for(;;)
|
} /* end: for(;;) */
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
_ENABLE_RWW_SECTION();
|
_ENABLE_RWW_SECTION();
|
||||||
funcptr(); // Jump to Reset vector 0x0000 in Application Section.
|
funcptr(); /* Jump to Reset vector 0x0000 in Application Section. */
|
||||||
}
|
}
|
||||||
} // end: main
|
} /* end: main */
|
||||||
|
|
||||||
|
|
||||||
#ifndef REMOVE_BLOCK_SUPPORT
|
#ifndef REMOVE_BLOCK_SUPPORT
|
||||||
unsigned char BlockLoad(unsigned int size, unsigned char mem, ADDR_T *address)
|
unsigned char BlockLoad(
|
||||||
|
unsigned int size,
|
||||||
|
unsigned char mem,
|
||||||
|
ADDR_T * address)
|
||||||
{
|
{
|
||||||
unsigned char buffer[BLOCKSIZE];
|
unsigned char buffer[BLOCKSIZE];
|
||||||
unsigned int data;
|
unsigned int data;
|
||||||
ADDR_T tempaddress;
|
ADDR_T tempaddress;
|
||||||
|
|
||||||
// EEPROM memory type.
|
/* EEPROM memory type. */
|
||||||
if(mem=='E')
|
if (mem == 'E') {
|
||||||
{
|
|
||||||
/* Fill buffer first, as EEPROM is too slow to copy with UART speed */
|
/* Fill buffer first, as EEPROM is too slow to copy with UART speed */
|
||||||
for (tempaddress = 0; tempaddress < size; tempaddress++)
|
for (tempaddress = 0; tempaddress < size; tempaddress++)
|
||||||
buffer[tempaddress] = recchar();
|
buffer[tempaddress] = recchar();
|
||||||
|
|
||||||
/* Then program the EEPROM */
|
/* Then program the EEPROM */
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
for( tempaddress=0; tempaddress < size; tempaddress++)
|
for (tempaddress = 0; tempaddress < size; tempaddress++) {
|
||||||
{
|
EEARL = *address; /* Setup EEPROM address */
|
||||||
EEARL = *address; // Setup EEPROM address
|
|
||||||
EEARH = ((*address) >> 8);
|
EEARH = ((*address) >> 8);
|
||||||
EEDR = buffer[tempaddress]; // Get byte.
|
EEDR = buffer[tempaddress]; /* Get byte. */
|
||||||
EECR |= (1<<EEMWE); // Write byte.
|
EECR |= (1 << EEMWE); /* Write byte. */
|
||||||
EECR |= (1 << EEWE);
|
EECR |= (1 << EEWE);
|
||||||
while (EECR & (1<<EEWE)) // Wait for write operation to finish.
|
while (EECR & (1 << EEWE)) /* Wait for write operation to finish. */
|
||||||
;
|
;
|
||||||
|
|
||||||
(*address)++; // Select next EEPROM byte
|
(*address)++; /* Select next EEPROM byte */
|
||||||
}
|
}
|
||||||
|
|
||||||
return '\r'; // Report programming OK
|
return '\r'; /* Report programming OK */
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flash memory type.
|
/* Flash memory type. */
|
||||||
else if(mem=='F')
|
else if (mem == 'F') { /* NOTE: For flash programming, 'address' is given in words. */
|
||||||
{ // NOTE: For flash programming, 'address' is given in words.
|
(*address) <<= 1; /* Convert address to bytes temporarily. */
|
||||||
(*address) <<= 1; // Convert address to bytes temporarily.
|
tempaddress = (*address); /* Store address in page. */
|
||||||
tempaddress = (*address); // Store address in page.
|
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
data = recchar();
|
data = recchar();
|
||||||
data |= (recchar() << 8);
|
data |= (recchar() << 8);
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_suppress=Pe1053 // Suppress warning for conversion from long-type address to flash ptr.
|
#pragma diag_suppress=Pe1053 /* Suppress warning for conversion from long-type address to flash ptr. */
|
||||||
#endif
|
#endif
|
||||||
_FILL_TEMP_WORD(*address, data);
|
_FILL_TEMP_WORD(*address, data);
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_default=Pe1053 // Back to default.
|
#pragma diag_default=Pe1053 /* Back to default. */
|
||||||
#endif
|
#endif
|
||||||
(*address)+=2; // Select next word in memory.
|
(*address) += 2; /* Select next word in memory. */
|
||||||
size -= 2; // Reduce number of bytes to write by two.
|
size -= 2; /* Reduce number of bytes to write by two. */
|
||||||
} while(size); // Loop until all bytes written.
|
} while (size); /* Loop until all bytes written. */
|
||||||
|
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_suppress=Pe1053 // Suppress warning for conversion from long-type address to flash ptr.
|
#pragma diag_suppress=Pe1053 /* Suppress warning for conversion from long-type address to flash ptr. */
|
||||||
#endif
|
#endif
|
||||||
_PAGE_WRITE(tempaddress);
|
_PAGE_WRITE(tempaddress);
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_default=Pe1053 // Back to default.
|
#pragma diag_default=Pe1053 /* Back to default. */
|
||||||
#endif
|
#endif
|
||||||
_WAIT_FOR_SPM();
|
_WAIT_FOR_SPM();
|
||||||
_ENABLE_RWW_SECTION();
|
_ENABLE_RWW_SECTION();
|
||||||
|
|
||||||
(*address) >>= 1; // Convert address back to Flash words again.
|
(*address) >>= 1; /* Convert address back to Flash words again. */
|
||||||
return '\r'; // Report programming OK
|
return '\r'; /* Report programming OK */
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalid memory type?
|
/* Invalid memory type? */
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
return '?';
|
return '?';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BlockRead(unsigned int size, unsigned char mem, ADDR_T *address)
|
void BlockRead(
|
||||||
|
unsigned int size,
|
||||||
|
unsigned char mem,
|
||||||
|
ADDR_T * address)
|
||||||
{
|
{
|
||||||
// EEPROM memory type.
|
/* EEPROM memory type. */
|
||||||
if (mem=='E') // Read EEPROM
|
if (mem == 'E') { /* Read EEPROM */
|
||||||
{
|
do {
|
||||||
do
|
EEARL = *address; /* Setup EEPROM address */
|
||||||
{
|
|
||||||
EEARL = *address; // Setup EEPROM address
|
|
||||||
EEARH = ((*address) >> 8);
|
EEARH = ((*address) >> 8);
|
||||||
(*address)++; // Select next EEPROM byte
|
(*address)++; /* Select next EEPROM byte */
|
||||||
EECR |= (1<<EERE); // Read EEPROM
|
EECR |= (1 << EERE); /* Read EEPROM */
|
||||||
sendchar(EEDR); // Transmit EEPROM dat ato PC
|
sendchar(EEDR); /* Transmit EEPROM dat ato PC */
|
||||||
|
|
||||||
size--; // Decrease number of bytes to read
|
size--; /* Decrease number of bytes to read */
|
||||||
} while (size); // Repeat until all block has been read
|
} while (size); /* Repeat until all block has been read */
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flash memory type.
|
/* Flash memory type. */
|
||||||
else if(mem=='F')
|
else if (mem == 'F') {
|
||||||
{
|
(*address) <<= 1; /* Convert address to bytes temporarily. */
|
||||||
(*address) <<= 1; // Convert address to bytes temporarily.
|
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_suppress=Pe1053 // Suppress warning for conversion from long-type address to flash ptr.
|
#pragma diag_suppress=Pe1053 /* Suppress warning for conversion from long-type address to flash ptr. */
|
||||||
#endif
|
#endif
|
||||||
sendchar(_LOAD_PROGRAM_MEMORY(*address));
|
sendchar(_LOAD_PROGRAM_MEMORY(*address));
|
||||||
sendchar(_LOAD_PROGRAM_MEMORY((*address) + 1));
|
sendchar(_LOAD_PROGRAM_MEMORY((*address) + 1));
|
||||||
#ifdef __ICCAVR__
|
#ifdef __ICCAVR__
|
||||||
#pragma diag_default=Pe1053 // Back to default.
|
#pragma diag_default=Pe1053 /* Back to default. */
|
||||||
#endif
|
#endif
|
||||||
(*address) += 2; // Select next word in memory.
|
(*address) += 2; /* Select next word in memory. */
|
||||||
size -= 2; // Subtract two bytes from number of bytes to read
|
size -= 2; /* Subtract two bytes from number of bytes to read */
|
||||||
} while (size); // Repeat until all block has been read
|
} while (size); /* Repeat until all block has been read */
|
||||||
|
|
||||||
(*address) >>= 1; // Convert address back to Flash words again.
|
(*address) >>= 1; /* Convert address back to Flash words again. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* REMOVE_BLOCK_SUPPORT */
|
#endif /* REMOVE_BLOCK_SUPPORT */
|
||||||
|
|||||||
@@ -19,24 +19,26 @@
|
|||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
|
|
||||||
void initbootuart(void)
|
void initbootuart(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
BAUD_RATE_LOW_REG = BRREG_VALUE;
|
BAUD_RATE_LOW_REG = BRREG_VALUE;
|
||||||
UART_CONTROL_REG = (1 << ENABLE_RECEIVER_BIT) |
|
UART_CONTROL_REG = (1 << ENABLE_RECEIVER_BIT) | (1 << ENABLE_TRANSMITTER_BIT); /* enable receive and transmit */
|
||||||
(1 << ENABLE_TRANSMITTER_BIT); // enable receive and transmit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void sendchar(unsigned char c)
|
void sendchar(
|
||||||
|
unsigned char c)
|
||||||
{
|
{
|
||||||
UART_DATA_REG = c; // prepare transmission
|
UART_DATA_REG = c; /* prepare transmission */
|
||||||
while (!(UART_STATUS_REG & (1 << TRANSMIT_COMPLETE_BIT)));// wait until byte sendt
|
while (!(UART_STATUS_REG & (1 << TRANSMIT_COMPLETE_BIT))); /* wait until byte sendt */
|
||||||
UART_STATUS_REG |= (1 << TRANSMIT_COMPLETE_BIT); // delete TXCflag
|
UART_STATUS_REG |= (1 << TRANSMIT_COMPLETE_BIT); /* delete TXCflag */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned char recchar(void)
|
unsigned char recchar(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
while(!(UART_STATUS_REG & (1 << RECEIVE_COMPLETE_BIT))); // wait for data
|
while (!(UART_STATUS_REG & (1 << RECEIVE_COMPLETE_BIT))); /* wait for data */
|
||||||
return UART_DATA_REG;
|
return UART_DATA_REG;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
* Description : Header file for serial.c
|
* Description : Header file for serial.c
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void initbootuart( void );
|
void initbootuart(
|
||||||
void sendchar( unsigned char );
|
void);
|
||||||
unsigned char recchar( void );
|
void sendchar(
|
||||||
|
unsigned char);
|
||||||
|
unsigned char recchar(
|
||||||
|
void);
|
||||||
|
|||||||
@@ -122,40 +122,26 @@ void Device_Init(
|
|||||||
Reinitialize_State = REINITIALIZED_STATE_IDLE;
|
Reinitialize_State = REINITIALIZED_STATE_IDLE;
|
||||||
dcc_set_status_duration(COMMUNICATION_ENABLE, 0);
|
dcc_set_status_duration(COMMUNICATION_ENABLE, 0);
|
||||||
/* Get the data from the eeprom */
|
/* Get the data from the eeprom */
|
||||||
eeprom_bytes_read(
|
eeprom_bytes_read(NV_EEPROM_DEVICE_0, (uint8_t *) & Object_Instance_Number,
|
||||||
NV_EEPROM_DEVICE_0,
|
|
||||||
(uint8_t *)&Object_Instance_Number,
|
|
||||||
sizeof(Object_Instance_Number));
|
sizeof(Object_Instance_Number));
|
||||||
if (Object_Instance_Number >= BACNET_MAX_INSTANCE) {
|
if (Object_Instance_Number >= BACNET_MAX_INSTANCE) {
|
||||||
Object_Instance_Number = 0;
|
Object_Instance_Number = 0;
|
||||||
eeprom_bytes_write(
|
eeprom_bytes_write(NV_EEPROM_DEVICE_0,
|
||||||
NV_EEPROM_DEVICE_0,
|
|
||||||
(uint8_t *) & Object_Instance_Number,
|
(uint8_t *) & Object_Instance_Number,
|
||||||
sizeof(Object_Instance_Number));
|
sizeof(Object_Instance_Number));
|
||||||
}
|
}
|
||||||
eeprom_bytes_read(
|
eeprom_bytes_read(NV_EEPROM_DEVICE_NAME_ENCODING, &Object_Name_Encoding,
|
||||||
NV_EEPROM_DEVICE_NAME_ENCODING,
|
|
||||||
&Object_Name_Encoding,
|
|
||||||
1);
|
1);
|
||||||
eeprom_bytes_read(
|
eeprom_bytes_read(NV_EEPROM_DEVICE_NAME_LENGTH, &Object_Name_Length, 1);
|
||||||
NV_EEPROM_DEVICE_NAME_LENGTH,
|
eeprom_bytes_read(NV_EEPROM_DEVICE_NAME_0, (uint8_t *) & Object_Name[0],
|
||||||
&Object_Name_Length,
|
|
||||||
1);
|
|
||||||
eeprom_bytes_read(
|
|
||||||
NV_EEPROM_DEVICE_NAME_0,
|
|
||||||
(uint8_t *)&Object_Name[0],
|
|
||||||
NV_EEPROM_DEVICE_NAME_SIZE);
|
NV_EEPROM_DEVICE_NAME_SIZE);
|
||||||
if ((Object_Name_Encoding >= MAX_CHARACTER_STRING_ENCODING) ||
|
if ((Object_Name_Encoding >= MAX_CHARACTER_STRING_ENCODING) ||
|
||||||
(Object_Name_Length > NV_EEPROM_DEVICE_NAME_SIZE)) {
|
(Object_Name_Length > NV_EEPROM_DEVICE_NAME_SIZE)) {
|
||||||
Object_Name_Encoding = CHARACTER_ANSI_X34;
|
Object_Name_Encoding = CHARACTER_ANSI_X34;
|
||||||
Object_Name_Length = 0;
|
Object_Name_Length = 0;
|
||||||
eeprom_bytes_write(
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_ENCODING,
|
||||||
NV_EEPROM_DEVICE_NAME_ENCODING,
|
&Object_Name_Encoding, 1);
|
||||||
&Object_Name_Encoding,
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH, &Object_Name_Length,
|
||||||
1);
|
|
||||||
eeprom_bytes_write(
|
|
||||||
NV_EEPROM_DEVICE_NAME_LENGTH,
|
|
||||||
&Object_Name_Length,
|
|
||||||
1);
|
1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,8 +160,7 @@ bool Device_Set_Object_Instance_Number(
|
|||||||
|
|
||||||
if (object_id <= BACNET_MAX_INSTANCE) {
|
if (object_id <= BACNET_MAX_INSTANCE) {
|
||||||
Object_Instance_Number = object_id;
|
Object_Instance_Number = object_id;
|
||||||
eeprom_bytes_write(
|
eeprom_bytes_write(NV_EEPROM_DEVICE_0,
|
||||||
NV_EEPROM_DEVICE_0,
|
|
||||||
(uint8_t *) & Object_Instance_Number,
|
(uint8_t *) & Object_Instance_Number,
|
||||||
sizeof(Object_Instance_Number));
|
sizeof(Object_Instance_Number));
|
||||||
} else
|
} else
|
||||||
@@ -334,10 +319,8 @@ int Device_Encode_Property_APDU(
|
|||||||
Object_Instance_Number);
|
Object_Instance_Number);
|
||||||
break;
|
break;
|
||||||
case PROP_OBJECT_NAME:
|
case PROP_OBJECT_NAME:
|
||||||
characterstring_init(&char_string,
|
characterstring_init(&char_string, Object_Name_Encoding,
|
||||||
Object_Name_Encoding,
|
(char *) &Object_Name[0], Object_Name_Length);
|
||||||
(char *)&Object_Name[0],
|
|
||||||
Object_Name_Length);
|
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_character_string(&apdu[0], &char_string);
|
encode_application_character_string(&apdu[0], &char_string);
|
||||||
break;
|
break;
|
||||||
@@ -590,23 +573,18 @@ bool Device_Write_Property(
|
|||||||
char *pCharString;
|
char *pCharString;
|
||||||
Object_Name_Encoding = encoding;
|
Object_Name_Encoding = encoding;
|
||||||
Object_Name_Length = length;
|
Object_Name_Length = length;
|
||||||
eeprom_bytes_write(
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_ENCODING,
|
||||||
NV_EEPROM_DEVICE_NAME_ENCODING,
|
&Object_Name_Encoding, 1);
|
||||||
&Object_Name_Encoding,
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH,
|
||||||
1);
|
&Object_Name_Length, 1);
|
||||||
eeprom_bytes_write(
|
|
||||||
NV_EEPROM_DEVICE_NAME_LENGTH,
|
|
||||||
&Object_Name_Length,
|
|
||||||
1);
|
|
||||||
pCharString =
|
pCharString =
|
||||||
characterstring_value(&value.type.Character_String);
|
characterstring_value(&value.type.
|
||||||
|
Character_String);
|
||||||
for (i = 0; i < Object_Name_Length; i++) {
|
for (i = 0; i < Object_Name_Length; i++) {
|
||||||
Object_Name[i] = pCharString[i];
|
Object_Name[i] = pCharString[i];
|
||||||
}
|
}
|
||||||
eeprom_bytes_write(
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0,
|
||||||
NV_EEPROM_DEVICE_NAME_0,
|
(uint8_t *) & Object_Name[0], length);
|
||||||
(uint8_t *)&Object_Name[0],
|
|
||||||
length);
|
|
||||||
status = true;
|
status = true;
|
||||||
} else {
|
} else {
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
|
|||||||
@@ -38,8 +38,8 @@
|
|||||||
int eeprom_bytes_read(
|
int eeprom_bytes_read(
|
||||||
uint16_t eeaddr, /* EEPROM starting memory address (offset of zero) */
|
uint16_t eeaddr, /* EEPROM starting memory address (offset of zero) */
|
||||||
uint8_t * buf, /* data to store */
|
uint8_t * buf, /* data to store */
|
||||||
int len) /* number of bytes of data to read */
|
int len)
|
||||||
{
|
{ /* number of bytes of data to read */
|
||||||
int count = 0; /* return value */
|
int count = 0; /* return value */
|
||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
@@ -55,8 +55,8 @@ int eeprom_bytes_read(
|
|||||||
int eeprom_bytes_write(
|
int eeprom_bytes_write(
|
||||||
uint16_t eeaddr, /* EEPROM starting memory address */
|
uint16_t eeaddr, /* EEPROM starting memory address */
|
||||||
uint8_t * buf, /* data to send */
|
uint8_t * buf, /* data to send */
|
||||||
int len) /* number of bytes of data */
|
int len)
|
||||||
{
|
{ /* number of bytes of data */
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
|
|||||||
@@ -46,8 +46,8 @@
|
|||||||
#include "bits.h"
|
#include "bits.h"
|
||||||
|
|
||||||
/* SEEPROM is 24LC128 */
|
/* SEEPROM is 24LC128 */
|
||||||
//#define SEEPROM_PAGE_SIZE 128
|
/*#define SEEPROM_PAGE_SIZE 128 */
|
||||||
//#define SEEPROM_WORD_ADDRESS_16BIT 1
|
/*#define SEEPROM_WORD_ADDRESS_16BIT 1 */
|
||||||
/* SEEPROM is 24C16 */
|
/* SEEPROM is 24C16 */
|
||||||
#define SEEPROM_PAGE_SIZE 16
|
#define SEEPROM_PAGE_SIZE 16
|
||||||
#define SEEPROM_WORD_ADDRESS_16BIT 0
|
#define SEEPROM_WORD_ADDRESS_16BIT 0
|
||||||
|
|||||||
@@ -30,10 +30,10 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
void init(void);
|
void init(
|
||||||
|
void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -42,21 +42,18 @@ void input_task(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t input_address(void)
|
uint8_t input_address(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
return Address_Switch;
|
return Address_Switch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void input_init(void)
|
void input_init(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
/* configure the port pins */
|
/* configure the port pins */
|
||||||
BITMASK_CLEAR(DDRA,
|
BITMASK_CLEAR(DDRA,
|
||||||
_BV(DDA0) |
|
_BV(DDA0) | _BV(DDA1) | _BV(DDA2) | _BV(DDA3) | _BV(DDA4) | _BV(DDA5) |
|
||||||
_BV(DDA1) |
|
|
||||||
_BV(DDA2) |
|
|
||||||
_BV(DDA3) |
|
|
||||||
_BV(DDA4) |
|
|
||||||
_BV(DDA5) |
|
|
||||||
_BV(DDA6)
|
_BV(DDA6)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,14 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
void input_init(void);
|
void input_init(
|
||||||
void input_task(void);
|
void);
|
||||||
uint8_t input_address(void);
|
void input_task(
|
||||||
|
void);
|
||||||
|
uint8_t input_address(
|
||||||
|
void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ static uint32_t Off_Delay_Milliseconds_4;
|
|||||||
* Returns: none
|
* Returns: none
|
||||||
* Notes: none
|
* Notes: none
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
void led_on(uint8_t index)
|
void led_on(
|
||||||
|
uint8_t index)
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case LED_1:
|
case LED_1:
|
||||||
@@ -61,7 +62,8 @@ void led_on(uint8_t index)
|
|||||||
* Returns: none
|
* Returns: none
|
||||||
* Notes: none
|
* Notes: none
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
void led_off(uint8_t index)
|
void led_off(
|
||||||
|
uint8_t index)
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case LED_1:
|
case LED_1:
|
||||||
@@ -86,7 +88,8 @@ void led_off(uint8_t index)
|
|||||||
* Returns: true if on, false if off.
|
* Returns: true if on, false if off.
|
||||||
* Notes: none
|
* Notes: none
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
bool led_state(uint8_t index)
|
bool led_state(
|
||||||
|
uint8_t index)
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case LED_1:
|
case LED_1:
|
||||||
@@ -113,7 +116,8 @@ bool led_state(uint8_t index)
|
|||||||
* Returns: none
|
* Returns: none
|
||||||
* Notes: none
|
* Notes: none
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
void led_toggle(uint8_t index)
|
void led_toggle(
|
||||||
|
uint8_t index)
|
||||||
{
|
{
|
||||||
if (led_state(index)) {
|
if (led_state(index)) {
|
||||||
led_off(index);
|
led_off(index);
|
||||||
@@ -127,7 +131,9 @@ void led_toggle(uint8_t index)
|
|||||||
* Returns: none
|
* Returns: none
|
||||||
* Notes: none
|
* Notes: none
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
void led_off_delay(uint8_t index, uint32_t delay_ms)
|
void led_off_delay(
|
||||||
|
uint8_t index,
|
||||||
|
uint32_t delay_ms)
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case LED_1:
|
case LED_1:
|
||||||
@@ -156,36 +162,29 @@ void led_off_delay(uint8_t index, uint32_t delay_ms)
|
|||||||
* Returns: none
|
* Returns: none
|
||||||
* Notes: none
|
* Notes: none
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
void led_task(void)
|
void led_task(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
if (Off_Delay_Milliseconds_1) {
|
if (Off_Delay_Milliseconds_1) {
|
||||||
if (timer_elapsed_milliseconds(
|
if (timer_elapsed_milliseconds(TIMER_LED_1, Off_Delay_Milliseconds_1)) {
|
||||||
TIMER_LED_1,
|
|
||||||
Off_Delay_Milliseconds_1)) {
|
|
||||||
Off_Delay_Milliseconds_1 = 0;
|
Off_Delay_Milliseconds_1 = 0;
|
||||||
led_off(LED_1);
|
led_off(LED_1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Off_Delay_Milliseconds_2) {
|
if (Off_Delay_Milliseconds_2) {
|
||||||
if (timer_elapsed_milliseconds(
|
if (timer_elapsed_milliseconds(TIMER_LED_2, Off_Delay_Milliseconds_2)) {
|
||||||
TIMER_LED_2,
|
|
||||||
Off_Delay_Milliseconds_2)) {
|
|
||||||
Off_Delay_Milliseconds_2 = 0;
|
Off_Delay_Milliseconds_2 = 0;
|
||||||
led_off(LED_2);
|
led_off(LED_2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Off_Delay_Milliseconds_3) {
|
if (Off_Delay_Milliseconds_3) {
|
||||||
if (timer_elapsed_milliseconds(
|
if (timer_elapsed_milliseconds(TIMER_LED_3, Off_Delay_Milliseconds_3)) {
|
||||||
TIMER_LED_3,
|
|
||||||
Off_Delay_Milliseconds_3)) {
|
|
||||||
Off_Delay_Milliseconds_3 = 0;
|
Off_Delay_Milliseconds_3 = 0;
|
||||||
led_off(LED_3);
|
led_off(LED_3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Off_Delay_Milliseconds_4) {
|
if (Off_Delay_Milliseconds_4) {
|
||||||
if (timer_elapsed_milliseconds(
|
if (timer_elapsed_milliseconds(TIMER_LED_4, Off_Delay_Milliseconds_4)) {
|
||||||
TIMER_LED_4,
|
|
||||||
Off_Delay_Milliseconds_4)) {
|
|
||||||
Off_Delay_Milliseconds_4 = 0;
|
Off_Delay_Milliseconds_4 = 0;
|
||||||
led_off(LED_4);
|
led_off(LED_4);
|
||||||
}
|
}
|
||||||
@@ -197,7 +196,8 @@ void led_task(void)
|
|||||||
* Returns: none
|
* Returns: none
|
||||||
* Notes: none
|
* Notes: none
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
void led_init(void)
|
void led_init(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
/* configure the port pins as outputs */
|
/* configure the port pins as outputs */
|
||||||
BIT_SET(DDRC, DDC7);
|
BIT_SET(DDRC, DDC7);
|
||||||
|
|||||||
@@ -37,16 +37,23 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
void led_on(uint8_t index);
|
void led_on(
|
||||||
void led_off(uint8_t index);
|
uint8_t index);
|
||||||
void led_off_delay(uint8_t index, uint32_t delay_ms);
|
void led_off(
|
||||||
void led_toggle(uint8_t index);
|
uint8_t index);
|
||||||
bool led_state(uint8_t index);
|
void led_off_delay(
|
||||||
void led_task(void);
|
uint8_t index,
|
||||||
void led_init(void);
|
uint32_t delay_ms);
|
||||||
|
void led_toggle(
|
||||||
|
uint8_t index);
|
||||||
|
bool led_state(
|
||||||
|
uint8_t index);
|
||||||
|
void led_task(
|
||||||
|
void);
|
||||||
|
void led_init(
|
||||||
|
void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -57,17 +57,13 @@ static uint8_t MSTP_MAC_Address;
|
|||||||
|
|
||||||
#if defined(__GNUC__) && (__GNUC__ > 4)
|
#if defined(__GNUC__) && (__GNUC__ > 4)
|
||||||
/* AVR fuse settings */
|
/* AVR fuse settings */
|
||||||
FUSES =
|
FUSES = {
|
||||||
{
|
|
||||||
/* External Ceramic Resonator - configuration */
|
/* External Ceramic Resonator - configuration */
|
||||||
/* Full Swing Crystal Oscillator Clock Selection */
|
/* Full Swing Crystal Oscillator Clock Selection */
|
||||||
/* Ceramic resonator, slowly rising power 1K CK 14CK + 65 ms */
|
/* Ceramic resonator, slowly rising power 1K CK 14CK + 65 ms */
|
||||||
/* note: fuses are enabled by clearing the bit, so
|
/* note: fuses are enabled by clearing the bit, so
|
||||||
any fuses listed below are cleared fuses. */
|
any fuses listed below are cleared fuses. */
|
||||||
.low = (FUSE_CKSEL3 &
|
.low = (FUSE_CKSEL3 & FUSE_SUT0 & FUSE_SUT1),
|
||||||
FUSE_SUT0 &
|
|
||||||
FUSE_SUT1),
|
|
||||||
|
|
||||||
/* BOOTSZ configuration:
|
/* BOOTSZ configuration:
|
||||||
BOOTSZ1 BOOTSZ0 Boot Size
|
BOOTSZ1 BOOTSZ0 Boot Size
|
||||||
------- ------- ---------
|
------- ------- ---------
|
||||||
@@ -78,13 +74,8 @@ FUSES =
|
|||||||
*/
|
*/
|
||||||
/* note: fuses are enabled by clearing the bit, so
|
/* note: fuses are enabled by clearing the bit, so
|
||||||
any fuses listed below are cleared fuses. */
|
any fuses listed below are cleared fuses. */
|
||||||
.high = (
|
.high =
|
||||||
FUSE_BOOTSZ1 &
|
(FUSE_BOOTSZ1 & FUSE_BOOTRST & FUSE_EESAVE & FUSE_SPIEN & FUSE_JTAGEN),
|
||||||
FUSE_BOOTRST &
|
|
||||||
FUSE_EESAVE &
|
|
||||||
FUSE_SPIEN &
|
|
||||||
FUSE_JTAGEN),
|
|
||||||
|
|
||||||
/* Brown-out detection VCC=2.7V */
|
/* Brown-out detection VCC=2.7V */
|
||||||
/* BODLEVEL configuration
|
/* BODLEVEL configuration
|
||||||
BODLEVEL2 BODLEVEL1 BODLEVEL0 Voltage
|
BODLEVEL2 BODLEVEL1 BODLEVEL0 Voltage
|
||||||
@@ -96,13 +87,14 @@ FUSES =
|
|||||||
*/
|
*/
|
||||||
/* note: fuses are enabled by clearing the bit, so
|
/* note: fuses are enabled by clearing the bit, so
|
||||||
any fuses listed below are cleared fuses. */
|
any fuses listed below are cleared fuses. */
|
||||||
.extended = (FUSE_BODLEVEL1 & FUSE_BODLEVEL0),
|
.extended = (FUSE_BODLEVEL1 & FUSE_BODLEVEL0),};
|
||||||
};
|
|
||||||
/* AVR lock bits - unlocked */
|
/* AVR lock bits - unlocked */
|
||||||
LOCKBITS = LOCKBITS_DEFAULT;
|
LOCKBITS = LOCKBITS_DEFAULT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool seeprom_version_test(void)
|
bool seeprom_version_test(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
uint16_t version = 0;
|
uint16_t version = 0;
|
||||||
uint16_t id = 0;
|
uint16_t id = 0;
|
||||||
@@ -157,7 +149,8 @@ static void bacnet_init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t PDUBuffer[MAX_MPDU];
|
static uint8_t PDUBuffer[MAX_MPDU];
|
||||||
static void bacnet_task(void)
|
static void bacnet_task(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
uint8_t mstp_mac_address = 0;
|
uint8_t mstp_mac_address = 0;
|
||||||
uint16_t pdu_len = 0;
|
uint16_t pdu_len = 0;
|
||||||
@@ -178,13 +171,15 @@ static void bacnet_task(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void idle_init(void)
|
void idle_init(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
timer_reset(TIMER_LED_3);
|
timer_reset(TIMER_LED_3);
|
||||||
timer_reset(TIMER_LED_4);
|
timer_reset(TIMER_LED_4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void idle_task(void)
|
void idle_task(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
/* blink the leds */
|
/* blink the leds */
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ static uint32_t Baud_Rate = 9600;
|
|||||||
static uint8_t Receive_Buffer_Data[128];
|
static uint8_t Receive_Buffer_Data[128];
|
||||||
static FIFO_BUFFER Receive_Buffer;
|
static FIFO_BUFFER Receive_Buffer;
|
||||||
|
|
||||||
static void rs485_rts_init(void)
|
static void rs485_rts_init(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
/* configure the port pin as an output */
|
/* configure the port pin as an output */
|
||||||
BIT_SET(DDRD, DDD4);
|
BIT_SET(DDRD, DDD4);
|
||||||
@@ -66,7 +67,8 @@ void rs485_rts_enable(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rs485_receiver_enable(void)
|
static void rs485_receiver_enable(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
UCSR0B = _BV(TXEN0) | _BV(RXEN0) | _BV(RXCIE0);
|
UCSR0B = _BV(TXEN0) | _BV(RXEN0) | _BV(RXCIE0);
|
||||||
}
|
}
|
||||||
@@ -112,15 +114,16 @@ bool rs485_byte_available(
|
|||||||
return data_available;
|
return data_available;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rs485_receive_error(void)
|
bool rs485_receive_error(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rs485_bytes_send(
|
void rs485_bytes_send(
|
||||||
uint8_t * buffer, /* data to send */
|
uint8_t * buffer, /* data to send */
|
||||||
uint16_t nbytes) /* number of bytes of data */
|
uint16_t nbytes)
|
||||||
{
|
{ /* number of bytes of data */
|
||||||
led_on(LED_2);
|
led_on(LED_2);
|
||||||
while (!BIT_CHECK(UCSR0A, UDRE0)) {
|
while (!BIT_CHECK(UCSR0A, UDRE0)) {
|
||||||
/* do nothing - wait until Tx buffer is empty */
|
/* do nothing - wait until Tx buffer is empty */
|
||||||
@@ -153,7 +156,8 @@ uint32_t rs485_baud_rate(
|
|||||||
return Baud_Rate;
|
return Baud_Rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rs485_baud_rate_configure(void)
|
static void rs485_baud_rate_configure(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
/* 2x speed mode */
|
/* 2x speed mode */
|
||||||
BIT_SET(UCSR0A, U2X0);
|
BIT_SET(UCSR0A, U2X0);
|
||||||
@@ -178,10 +182,7 @@ bool rs485_baud_rate_set(
|
|||||||
rs485_baud_rate_configure();
|
rs485_baud_rate_configure();
|
||||||
/* store the baud rate */
|
/* store the baud rate */
|
||||||
baud_k = baud / 1000;
|
baud_k = baud / 1000;
|
||||||
eeprom_bytes_write(
|
eeprom_bytes_write(NV_EEPROM_BAUD_K, &baud_k, 1);
|
||||||
NV_EEPROM_BAUD_K,
|
|
||||||
&baud_k,
|
|
||||||
1);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
valid = false;
|
valid = false;
|
||||||
@@ -191,7 +192,8 @@ bool rs485_baud_rate_set(
|
|||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rs485_usart_init(void)
|
static void rs485_usart_init(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
/* enable Transmit and Receive */
|
/* enable Transmit and Receive */
|
||||||
UCSR0B = _BV(TXEN0) | _BV(RXEN0);
|
UCSR0B = _BV(TXEN0) | _BV(RXEN0);
|
||||||
@@ -207,14 +209,12 @@ static void rs485_usart_init(void)
|
|||||||
BIT_CLEAR(PRR, PRUSART0);
|
BIT_CLEAR(PRR, PRUSART0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rs485_init_nvdata(void)
|
static void rs485_init_nvdata(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
uint8_t baud_k = 9; /* from EEPROM value */
|
uint8_t baud_k = 9; /* from EEPROM value */
|
||||||
|
|
||||||
eeprom_bytes_read(
|
eeprom_bytes_read(NV_EEPROM_BAUD_K, &baud_k, 1);
|
||||||
NV_EEPROM_BAUD_K,
|
|
||||||
&baud_k,
|
|
||||||
1);
|
|
||||||
switch (baud_k) {
|
switch (baud_k) {
|
||||||
case 9:
|
case 9:
|
||||||
Baud_Rate = 9600;
|
Baud_Rate = 9600;
|
||||||
@@ -238,16 +238,14 @@ static void rs485_init_nvdata(void)
|
|||||||
/* not configured yet */
|
/* not configured yet */
|
||||||
Baud_Rate = 38400;
|
Baud_Rate = 38400;
|
||||||
baud_k = 38400 / 1000;
|
baud_k = 38400 / 1000;
|
||||||
eeprom_bytes_write(
|
eeprom_bytes_write(NV_EEPROM_BAUD_K, &baud_k, 1);
|
||||||
NV_EEPROM_BAUD_K,
|
|
||||||
&baud_k,
|
|
||||||
1);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rs485_baud_rate_configure();
|
rs485_baud_rate_configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
void rs485_init(void)
|
void rs485_init(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
FIFO_Init(&Receive_Buffer, &Receive_Buffer_Data[0],
|
FIFO_Init(&Receive_Buffer, &Receive_Buffer_Data[0],
|
||||||
(unsigned) sizeof(Receive_Buffer_Data));
|
(unsigned) sizeof(Receive_Buffer_Data));
|
||||||
|
|||||||
@@ -42,16 +42,19 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
void rs485_init(void);
|
void rs485_init(
|
||||||
|
void);
|
||||||
void rs485_rts_enable(
|
void rs485_rts_enable(
|
||||||
bool enable);
|
bool enable);
|
||||||
bool rs485_byte_available(
|
bool rs485_byte_available(
|
||||||
uint8_t * data_register);
|
uint8_t * data_register);
|
||||||
bool rs485_receive_error(void);
|
bool rs485_receive_error(
|
||||||
|
void);
|
||||||
void rs485_bytes_send(
|
void rs485_bytes_send(
|
||||||
uint8_t * buffer, /* data to send */
|
uint8_t * buffer, /* data to send */
|
||||||
uint16_t nbytes); /* number of bytes of data */
|
uint16_t nbytes); /* number of bytes of data */
|
||||||
uint32_t rs485_baud_rate(void);
|
uint32_t rs485_baud_rate(
|
||||||
|
void);
|
||||||
bool rs485_baud_rate_set(
|
bool rs485_baud_rate_set(
|
||||||
uint32_t baud);
|
uint32_t baud);
|
||||||
|
|
||||||
|
|||||||
@@ -102,8 +102,8 @@
|
|||||||
int seeprom_bytes_read(
|
int seeprom_bytes_read(
|
||||||
uint16_t eeaddr, /* SEEPROM starting memory address */
|
uint16_t eeaddr, /* SEEPROM starting memory address */
|
||||||
uint8_t * buf, /* data to store */
|
uint8_t * buf, /* data to store */
|
||||||
int len) /* number of bytes of data to read */
|
int len)
|
||||||
{
|
{ /* number of bytes of data to read */
|
||||||
uint8_t sla, twcr, n = 0;
|
uint8_t sla, twcr, n = 0;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
uint8_t twst; /* status - only valid while TWINT is set. */
|
uint8_t twst; /* status - only valid while TWINT is set. */
|
||||||
@@ -279,8 +279,8 @@ error:
|
|||||||
int seeprom_bytes_write(
|
int seeprom_bytes_write(
|
||||||
uint16_t eeaddr, /* SEEPROM starting memory address */
|
uint16_t eeaddr, /* SEEPROM starting memory address */
|
||||||
uint8_t * buf, /* data to send */
|
uint8_t * buf, /* data to send */
|
||||||
int len) /* number of bytes of data */
|
int len)
|
||||||
{
|
{ /* number of bytes of data */
|
||||||
uint8_t sla, n = 0;
|
uint8_t sla, n = 0;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
uint16_t endaddr;
|
uint16_t endaddr;
|
||||||
@@ -365,7 +365,8 @@ begin:
|
|||||||
/* clear interrupt to start transmission */
|
/* clear interrupt to start transmission */
|
||||||
TWCR = _BV(TWINT) | _BV(TWEN);
|
TWCR = _BV(TWINT) | _BV(TWEN);
|
||||||
/* wait for transmission */
|
/* wait for transmission */
|
||||||
while ((TWCR & _BV(TWINT)) == 0) {};
|
while ((TWCR & _BV(TWINT)) == 0) {
|
||||||
|
};
|
||||||
twst = TWSR & TW_STATUS_MASK;
|
twst = TWSR & TW_STATUS_MASK;
|
||||||
switch (twst) {
|
switch (twst) {
|
||||||
case TW_MT_DATA_ACK:
|
case TW_MT_DATA_ACK:
|
||||||
@@ -412,7 +413,8 @@ error:
|
|||||||
* Returns: none
|
* Returns: none
|
||||||
* Notes: none
|
* Notes: none
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
void seeprom_init(void)
|
void seeprom_init(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
/* bit rate prescaler */
|
/* bit rate prescaler */
|
||||||
TWSR = 0;
|
TWSR = 0;
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ static uint32_t Baud_Rate = 9600;
|
|||||||
static uint8_t Receive_Buffer_Data[128];
|
static uint8_t Receive_Buffer_Data[128];
|
||||||
static FIFO_BUFFER Receive_Buffer;
|
static FIFO_BUFFER Receive_Buffer;
|
||||||
|
|
||||||
static void serial_receiver_enable(void)
|
static void serial_receiver_enable(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
UCSR0B = _BV(TXEN0) | _BV(RXEN0) | _BV(RXCIE0);
|
UCSR0B = _BV(TXEN0) | _BV(RXEN0) | _BV(RXCIE0);
|
||||||
}
|
}
|
||||||
@@ -79,8 +80,8 @@ bool serial_byte_peek(
|
|||||||
|
|
||||||
void serial_bytes_send(
|
void serial_bytes_send(
|
||||||
uint8_t * buffer, /* data to send */
|
uint8_t * buffer, /* data to send */
|
||||||
uint16_t nbytes) /* number of bytes of data */
|
uint16_t nbytes)
|
||||||
{
|
{ /* number of bytes of data */
|
||||||
while (!BIT_CHECK(UCSR1A, UDRE1)) {
|
while (!BIT_CHECK(UCSR1A, UDRE1)) {
|
||||||
/* do nothing - wait until Tx buffer is empty */
|
/* do nothing - wait until Tx buffer is empty */
|
||||||
}
|
}
|
||||||
@@ -104,7 +105,8 @@ void serial_bytes_send(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_byte_send(uint8_t ch)
|
void serial_byte_send(
|
||||||
|
uint8_t ch)
|
||||||
{
|
{
|
||||||
uint8_t buffer[1];
|
uint8_t buffer[1];
|
||||||
|
|
||||||
@@ -147,7 +149,8 @@ bool serial_baud_rate_set(
|
|||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void serial_usart_init(void)
|
static void serial_usart_init(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
/* enable Transmit and Receive */
|
/* enable Transmit and Receive */
|
||||||
UCSR1B = _BV(TXEN1) | _BV(RXEN1);
|
UCSR1B = _BV(TXEN1) | _BV(RXEN1);
|
||||||
@@ -163,7 +166,8 @@ static void serial_usart_init(void)
|
|||||||
BIT_CLEAR(PRR, PRUSART1);
|
BIT_CLEAR(PRR, PRUSART1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_init(void)
|
void serial_init(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
FIFO_Init(&Receive_Buffer, &Receive_Buffer_Data[0],
|
FIFO_Init(&Receive_Buffer, &Receive_Buffer_Data[0],
|
||||||
(unsigned) sizeof(Receive_Buffer_Data));
|
(unsigned) sizeof(Receive_Buffer_Data));
|
||||||
|
|||||||
@@ -38,16 +38,18 @@ bool serial_byte_peek(
|
|||||||
void serial_bytes_send(
|
void serial_bytes_send(
|
||||||
uint8_t * buffer, /* data to send */
|
uint8_t * buffer, /* data to send */
|
||||||
uint16_t nbytes); /* number of bytes of data */
|
uint16_t nbytes); /* number of bytes of data */
|
||||||
void serial_byte_send(uint8_t ch);
|
void serial_byte_send(
|
||||||
|
uint8_t ch);
|
||||||
|
|
||||||
uint32_t serial_baud_rate(void);
|
uint32_t serial_baud_rate(
|
||||||
|
void);
|
||||||
bool serial_baud_rate_set(
|
bool serial_baud_rate_set(
|
||||||
uint32_t baud);
|
uint32_t baud);
|
||||||
|
|
||||||
void serial_init(void);
|
void serial_init(
|
||||||
|
void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -51,17 +51,20 @@ void stack_init(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned stack_size(void)
|
unsigned stack_size(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
return (&__stack) - (&_end);
|
return (&__stack) - (&_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t stack_byte(unsigned offset)
|
uint8_t stack_byte(
|
||||||
|
unsigned offset)
|
||||||
{
|
{
|
||||||
return *(&_end + offset);
|
return *(&_end + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned stack_unused(void)
|
unsigned stack_unused(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
uint8_t *p = &_end;
|
uint8_t *p = &_end;
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
|
|||||||
@@ -33,17 +33,19 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* C stack checking */
|
/* C stack checking */
|
||||||
void stack_init(void);
|
void stack_init(
|
||||||
|
void);
|
||||||
|
|
||||||
unsigned stack_size(void);
|
unsigned stack_size(
|
||||||
|
void);
|
||||||
|
|
||||||
uint8_t stack_byte(unsigned offset);
|
uint8_t stack_byte(
|
||||||
|
unsigned offset);
|
||||||
|
|
||||||
unsigned stack_unused(void);
|
unsigned stack_unused(
|
||||||
|
void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ static volatile unsigned long Millisecond_Counter[MAX_MILLISECOND_TIMERS];
|
|||||||
* Returns: none
|
* Returns: none
|
||||||
* Notes: Global interupts must be enabled
|
* Notes: Global interupts must be enabled
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
static inline void timer_interrupt_handler(void)
|
static inline void timer_interrupt_handler(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
unsigned i; /* loop counter */
|
unsigned i; /* loop counter */
|
||||||
|
|
||||||
|
|||||||
@@ -119,14 +119,8 @@ static void RS485_Print_Error(
|
|||||||
DWORD dwExtSize;
|
DWORD dwExtSize;
|
||||||
DWORD dwErr;
|
DWORD dwErr;
|
||||||
|
|
||||||
FormatMessage(
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
(LPTSTR) & lpMsgBuf, 0, NULL);
|
||||||
NULL,
|
|
||||||
GetLastError(),
|
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
|
||||||
(LPTSTR) &lpMsgBuf,
|
|
||||||
0,
|
|
||||||
NULL );
|
|
||||||
MessageBox(NULL, lpMsgBuf, "GetLastError", MB_OK | MB_ICONINFORMATION);
|
MessageBox(NULL, lpMsgBuf, "GetLastError", MB_OK | MB_ICONINFORMATION);
|
||||||
LocalFree(lpMsgBuf);
|
LocalFree(lpMsgBuf);
|
||||||
|
|
||||||
|
|||||||
@@ -809,34 +809,29 @@ bool bacapp_print_value(
|
|||||||
if (value->type.Date.day == 255) {
|
if (value->type.Date.day == 255) {
|
||||||
fprintf(stream, "(unspecified), ");
|
fprintf(stream, "(unspecified), ");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stream, "%u, ",
|
fprintf(stream, "%u, ", (unsigned) value->type.Date.day);
|
||||||
(unsigned) value->type.Date.day);
|
|
||||||
}
|
}
|
||||||
if (value->type.Date.year == 255) {
|
if (value->type.Date.year == 255) {
|
||||||
fprintf(stream, "(unspecified), ");
|
fprintf(stream, "(unspecified), ");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stream, "%u",
|
fprintf(stream, "%u", (unsigned) value->type.Date.year);
|
||||||
(unsigned) value->type.Date.year);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_TIME:
|
case BACNET_APPLICATION_TAG_TIME:
|
||||||
if (value->type.Time.hour == 255) {
|
if (value->type.Time.hour == 255) {
|
||||||
fprintf(stream, "**:");
|
fprintf(stream, "**:");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stream, "%02u:",
|
fprintf(stream, "%02u:", (unsigned) value->type.Time.hour);
|
||||||
(unsigned) value->type.Time.hour);
|
|
||||||
}
|
}
|
||||||
if (value->type.Time.min == 255) {
|
if (value->type.Time.min == 255) {
|
||||||
fprintf(stream, "**:");
|
fprintf(stream, "**:");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stream, "%02u:",
|
fprintf(stream, "%02u:", (unsigned) value->type.Time.min);
|
||||||
(unsigned) value->type.Time.min);
|
|
||||||
}
|
}
|
||||||
if (value->type.Time.sec == 255) {
|
if (value->type.Time.sec == 255) {
|
||||||
fprintf(stream, "**.");
|
fprintf(stream, "**.");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stream, "%02u.",
|
fprintf(stream, "%02u.", (unsigned) value->type.Time.sec);
|
||||||
(unsigned) value->type.Time.sec);
|
|
||||||
}
|
}
|
||||||
if (value->type.Time.hundredths == 255) {
|
if (value->type.Time.hundredths == 255) {
|
||||||
fprintf(stream, "**");
|
fprintf(stream, "**");
|
||||||
|
|||||||
Reference in New Issue
Block a user