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