Ran indent script.

This commit is contained in:
skarg
2009-07-29 18:06:33 +00:00
parent 551f2767e0
commit db61a1122f
37 changed files with 227 additions and 218 deletions
+31 -30
View File
@@ -27,22 +27,22 @@
/* prescale select bits */
#if (F_CPU >> 1) < 1000000
#define ADPS_8BIT (1)
#define ADPS_10BIT (3)
#define ADPS_8BIT (1)
#define ADPS_10BIT (3)
#elif (F_CPU >> 2) < 1000000
#define ADPS_8BIT (2)
#define ADPS_10BIT (4)
#define ADPS_8BIT (2)
#define ADPS_10BIT (4)
#elif (F_CPU >> 3) < 1000000
#define ADPS_8BIT (3)
#define ADPS_10BIT (5)
#define ADPS_8BIT (3)
#define ADPS_10BIT (5)
#elif (F_CPU >> 4) < 1000000
#define ADPS_8BIT (4)
#define ADPS_10BIT (6)
#define ADPS_8BIT (4)
#define ADPS_10BIT (6)
#elif (F_CPU >> 5) < 1000000
#define ADPS_8BIT (5)
#define ADPS_10BIT (7)
#define ADPS_8BIT (5)
#define ADPS_10BIT (7)
#else
#error "ADC: F_CPU too large for accuracy."
#error "ADC: F_CPU too large for accuracy."
#endif
/* we could have array of ADC results */
@@ -55,37 +55,38 @@ ISR(ADC_vect)
}
uint8_t adc_result(
uint8_t channel) /* 0..7 = ADC0..ADC7, respectively */
{
uint8_t channel)
{ /* 0..7 = ADC0..ADC7, respectively */
return Sample_Result;
}
void adc_init(void)
void adc_init(
void)
{
/* set prescaler */
ADCSRA |= ADPS_8BIT;
/* Initial channel selection */
/* ADLAR = Left Adjust Result
REFSx = hardware setup: cap on AREF
*/
ADMUX = 7 /* channel */ | (1 << ADLAR) | (0 << REFS1) | (1 << REFS0);
*/
ADMUX = 7 /* channel */ | (1 << ADLAR) | (0 << REFS1) | (1 << REFS0);
/* ADEN = Enable
ADSC = Start conversion
ADIF = Interrupt Flag
ADIE = Interrupt Enable
ADATE = Auto Trigger Enable
*/
ADSC = Start conversion
ADIF = Interrupt Flag
ADIE = Interrupt Enable
ADATE = Auto Trigger Enable
*/
ADCSRA |= (1 << ADEN) | (1 << ADIE) | (1 << ADIF) | (1 << ADATE);
/* trigger selection bits
0 0 0 Free Running mode
0 0 1 Analog Comparator
0 1 0 External Interrupt Request 0
0 1 1 Timer/Counter0 Compare Match
1 0 0 Timer/Counter0 Overflow
1 0 1 Timer/Counter1 Compare Match B
1 1 0 Timer/Counter1 Overflow
1 1 1 Timer/Counter1 Capture Event
*/
0 0 0 Free Running mode
0 0 1 Analog Comparator
0 1 0 External Interrupt Request 0
0 1 1 Timer/Counter0 Compare Match
1 0 0 Timer/Counter0 Overflow
1 0 1 Timer/Counter1 Compare Match B
1 1 0 Timer/Counter1 Overflow
1 1 1 Timer/Counter1 Capture Event
*/
ADCSRB |= (0 << ADTS2) | (0 << ADTS1) | (0 << ADTS0);
/* start the conversions */
ADCSRA |= (1 << ADSC);
+4 -3
View File
@@ -30,11 +30,12 @@
extern "C" {
#endif /* __cplusplus */
uint8_t adc_result(uint8_t channel);
void adc_init(void);
uint8_t adc_result(
uint8_t channel);
void adc_init(
void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+7 -11
View File
@@ -29,9 +29,9 @@
#include <stdint.h>
#include <stdio.h>
#if defined(__GNUC__) && (__GNUC__ > 4) && (__GNUC_MINOR__ > 2)
#include <math.h> /* for NAN */
#include <math.h> /* for NAN */
#else
#define NAN __builtin_nan("")
#define NAN __builtin_nan("")
#endif
#include "bacdef.h"
@@ -209,7 +209,7 @@ int Analog_Value_Encode_Property_APDU(
unsigned i = 0;
bool state = false;
#endif
switch (property) {
case PROP_OBJECT_IDENTIFIER:
apdu_len =
@@ -346,10 +346,8 @@ bool Analog_Value_Write_Property(
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_REAL) {
if (Analog_Value_Present_Value_Set(
wp_data->object_instance,
value.type.Real,
wp_data->priority)) {
if (Analog_Value_Present_Value_Set(wp_data->object_instance,
value.type.Real, wp_data->priority)) {
status = true;
} else if (wp_data->priority == 6) {
/* Command priority 6 is reserved for use by Minimum On/Off
@@ -363,10 +361,8 @@ bool Analog_Value_Write_Property(
}
#if 0
} else if (value.tag == BACNET_APPLICATION_TAG_NULL) {
if (Analog_Value_Present_Value_Set(
wp_data->object_instance,
NAN,
wp_data->priority)) {
if (Analog_Value_Present_Value_Set(wp_data->object_instance,
NAN, wp_data->priority)) {
status = true;
} else {
*error_class = ERROR_CLASS_PROPERTY;
+1 -1
View File
@@ -157,7 +157,7 @@ bool Binary_Input_Present_Value_Set(
}
return true;
}
return false;
}
+3 -3
View File
@@ -175,7 +175,7 @@ static BACNET_BINARY_PV Present_Value(
BACNET_BINARY_PV value = RELINQUISH_DEFAULT;
BACNET_BINARY_PV current_value = RELINQUISH_DEFAULT;
unsigned i = 0;
if (index < MAX_BINARY_OUTPUTS) {
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
current_value = Binary_Output_Level[index][i];
@@ -203,7 +203,7 @@ void Binary_Output_Level_Sync(
unsigned int index)
{
BACNET_BINARY_PV pv;
if (index < MAX_BINARY_OUTPUTS) {
if (Out_Of_Service[index]) {
return;
@@ -351,7 +351,7 @@ int Binary_Output_Encode_Property_APDU(
Binary_Output_Instance_To_Index(object_instance);
if (array_index <= BACNET_MAX_PRIORITY) {
present_value =
Binary_Output_Level[object_index][array_index-1];
Binary_Output_Level[object_index][array_index - 1];
if (present_value == BINARY_NULL) {
len = encode_application_null(&apdu[apdu_len]);
} else {
+24 -25
View File
@@ -33,31 +33,30 @@ FUSES = {
/* note: fuses are enabled by clearing the bit, so
any fuses listed below are cleared fuses. */
.low = (FUSE_CKSEL3 & FUSE_SUT0 & FUSE_SUT1),
/* BOOTSZ configuration:
BOOTSZ1 BOOTSZ0 Boot Size
------- ------- ---------
1 1 512
1 0 1024
0 1 2048
0 0 4096
*/
/* 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),
/* Brown-out detection VCC=2.7V */
/* BODLEVEL configuration
BODLEVEL2 BODLEVEL1 BODLEVEL0 Voltage
--------- --------- --------- --------
1 1 1 disabled
1 1 0 1.8V
1 0 1 2.7V
1 0 0 4.3V
*/
/* note: fuses are enabled by clearing the bit, so
any fuses listed below are cleared fuses. */
.extended = (FUSE_BODLEVEL1 & FUSE_BODLEVEL0)
/* BOOTSZ configuration:
BOOTSZ1 BOOTSZ0 Boot Size
------- ------- ---------
1 1 512
1 0 1024
0 1 2048
0 0 4096
*/
/* 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),
/* Brown-out detection VCC=2.7V */
/* BODLEVEL configuration
BODLEVEL2 BODLEVEL1 BODLEVEL0 Voltage
--------- --------- --------- --------
1 1 1 disabled
1 1 0 1.8V
1 0 1 2.7V
1 0 0 4.3V
*/
/* note: fuses are enabled by clearing the bit, so
any fuses listed below are cleared fuses. */
.extended = (FUSE_BODLEVEL1 & FUSE_BODLEVEL0)
};
/* AVR lock bits - unlocked */
+9 -8
View File
@@ -34,7 +34,8 @@ static uint8_t Buttons;
#if BDK_V1_HACK
/* version 1 BDK workaournd for floating inputs */
static void input_switch_workaround(void)
static void input_switch_workaround(
void)
{
/* configure the port pins for the switch - as outputs */
BIT_SET(DDRA, DDA0);
@@ -60,7 +61,7 @@ static void input_switch_workaround(void)
BIT_CLEAR(DDRA, DDA4);
BIT_CLEAR(DDRA, DDA5);
BIT_CLEAR(DDRA, DDA6);
return;
}
#endif
@@ -74,17 +75,17 @@ void input_task(
static uint8_t old_buttons = 0;
/* only check the inputs every debounce time */
if (timer_elapsed_milliseconds(TIMER_DEBOUNCE,30)) {
if (timer_elapsed_milliseconds(TIMER_DEBOUNCE, 30)) {
timer_reset(TIMER_DEBOUNCE);
/* pins used are PA6, PA5, PA4, PA3, PA2, PA1, PA0 */
#if BDK_V1_HACK
/* version 1 BDK - workaround */
value = (PINA&0x7F);
value = (PINA & 0x7F);
#else
/* version 2 BDK - has inverted inputs */
value = ~PINA;
value &= 0x7F;
#endif
#endif
if (value == old_address) {
/* stable value */
Address_Switch = old_address;
@@ -111,7 +112,7 @@ bool input_button_value(
uint8_t index)
{
bool value = false;
switch (index) {
case 0:
value = BIT_CHECK(Buttons, 0);
@@ -131,8 +132,8 @@ bool input_button_value(
default:
break;
}
return value;
return value;
}
+12 -11
View File
@@ -159,10 +159,11 @@ void idle_init(
void idle_task(
void)
{
/* do nothing */
/* do nothing */
}
void test_init(void)
void test_init(
void)
{
timer_reset(TIMER_LED_3);
timer_reset(TIMER_LED_4);
@@ -170,21 +171,21 @@ void test_init(void)
}
void test_task(
void)
void)
{
uint8_t buffer[32] = "BACnet: 0000000\r\n";
uint8_t nbytes = 17;
uint8_t data_register = 0;
if (timer_elapsed_seconds(TIMER_TEST, 1)) {
timer_reset(TIMER_TEST);
buffer[8] = (MSTP_MAC_Address&BIT0)?'1':'0';
buffer[9] = (MSTP_MAC_Address&BIT1)?'1':'0';
buffer[10] = (MSTP_MAC_Address&BIT2)?'1':'0';
buffer[11] = (MSTP_MAC_Address&BIT3)?'1':'0';
buffer[12] = (MSTP_MAC_Address&BIT4)?'1':'0';
buffer[13] = (MSTP_MAC_Address&BIT5)?'1':'0';
buffer[14] = (MSTP_MAC_Address&BIT6)?'1':'0';
buffer[8] = (MSTP_MAC_Address & BIT0) ? '1' : '0';
buffer[9] = (MSTP_MAC_Address & BIT1) ? '1' : '0';
buffer[10] = (MSTP_MAC_Address & BIT2) ? '1' : '0';
buffer[11] = (MSTP_MAC_Address & BIT3) ? '1' : '0';
buffer[12] = (MSTP_MAC_Address & BIT4) ? '1' : '0';
buffer[13] = (MSTP_MAC_Address & BIT5) ? '1' : '0';
buffer[14] = (MSTP_MAC_Address & BIT6) ? '1' : '0';
serial_bytes_send(buffer, nbytes);
}
if (serial_byte_get(&data_register)) {
+2 -1
View File
@@ -117,7 +117,8 @@ void serial_byte_send(
return;
}
void serial_byte_transmit_complete(void)
void serial_byte_transmit_complete(
void)
{
/* was the frame sent? */
while (!BIT_CHECK(UCSR1A, TXC1)) {
+3 -2
View File
@@ -38,11 +38,12 @@ extern "C" {
void serial_bytes_send(
uint8_t * buffer, /* data to send */
uint16_t nbytes); /* number of bytes of data */
/* byte transmit */
void serial_byte_send(
uint8_t ch);
void serial_byte_transmit_complete(void);
void serial_byte_transmit_complete(
void);
uint32_t serial_baud_rate(
void);
+16 -14
View File
@@ -33,16 +33,18 @@ static volatile uint32_t Millisecond_Counter[MAX_MILLISECOND_TIMERS];
/* start time for the clock */
static struct timespec start;
uint32_t timeGetTime(void)
uint32_t timeGetTime(
void)
{
struct timespec now;
uint32_t ticks;
clock_gettime(CLOCK_MONOTONIC,&now);
ticks = (now.tv_sec-start.tv_sec)*1000+
(now.tv_nsec-start.tv_nsec)/1000000;
clock_gettime(CLOCK_MONOTONIC, &now);
ticks =
(now.tv_sec - start.tv_sec) * 1000 + (now.tv_nsec -
start.tv_nsec) / 1000000;
return ticks;
}
@@ -56,7 +58,7 @@ uint32_t timer_milliseconds(
{
uint32_t now = timeGetTime();
uint32_t delta_time = 0;
if (index < MAX_MILLISECOND_TIMERS) {
if (Millisecond_Counter[index] <= now) {
delta_time = now - Millisecond_Counter[index];
@@ -64,7 +66,7 @@ uint32_t timer_milliseconds(
delta_time = (UINT32_MAX - Millisecond_Counter[index]) + now + 1;
}
}
return delta_time;
}
@@ -89,7 +91,7 @@ bool timer_elapsed_seconds(
unsigned index,
uint32_t seconds)
{
return ((timer_milliseconds(index)/1000) >= seconds);
return ((timer_milliseconds(index) / 1000) >= seconds);
}
/*************************************************************************
@@ -101,7 +103,7 @@ bool timer_elapsed_minutes(
unsigned index,
uint32_t minutes)
{
return ((timer_milliseconds(index)/(1000*60)) >= minutes);
return ((timer_milliseconds(index) / (1000 * 60)) >= minutes);
}
/*************************************************************************
@@ -113,12 +115,12 @@ uint32_t timer_reset(
unsigned index)
{
uint32_t timer_value = 0;
if (index < MAX_MILLISECOND_TIMERS) {
timer_value = timer_milliseconds(index);
Millisecond_Counter[index] = timeGetTime();
}
return timer_value;
}
@@ -130,5 +132,5 @@ uint32_t timer_reset(
void timer_init(
void)
{
clock_gettime(CLOCK_MONOTONIC,&start);
clock_gettime(CLOCK_MONOTONIC, &start);
}
+4 -3
View File
@@ -29,14 +29,15 @@
/* Timer Module */
#ifndef MAX_MILLISECOND_TIMERS
#define TIMER_SILENCE 0
#define MAX_MILLISECOND_TIMERS 1
#define TIMER_SILENCE 0
#define MAX_MILLISECOND_TIMERS 1
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
uint32_t timeGetTime(void);
uint32_t timeGetTime(
void);
void timer_init(
void);
+5 -4
View File
@@ -40,7 +40,7 @@
#define WIN32_LEAN_AND_MEAN
#define STRICT 1
#include <windows.h>
#include <MMSystem.h> /* for multimedia timers */
#include <MMSystem.h> /* for multimedia timers */
/* Number of MS/TP Packets Rx/Tx */
uint16_t MSTP_Packets = 0;
@@ -77,7 +77,7 @@ static uint16_t Timer_Silence(
delta_time = 0xFFFF;
}
return (uint16_t)delta_time;
return (uint16_t) delta_time;
}
static void Timer_Silence_Reset(
@@ -659,9 +659,10 @@ bool dlmstp_init(
#endif
/* set timer resolution */
if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) {
fprintf(stderr, "Failed to set timer resolution\n");
fprintf(stderr, "Failed to set timer resolution\n");
}
TimeBeginPeriod = min(max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax);
TimeBeginPeriod =
min(max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax);
timeBeginPeriod(TimeBeginPeriod);
/* start the threads */
+5 -5
View File
@@ -29,7 +29,7 @@
#define WIN32_LEAN_AND_MEAN
#define STRICT 1
#include <windows.h>
#include <MMSystem.h>
#include <MMSystem.h>
#include "timer.h"
/* counter for the various timers */
@@ -63,7 +63,7 @@ uint32_t timer_milliseconds(
{
uint32_t now = timeGetTime();
uint32_t delta_time = 0;
if (index < MAX_MILLISECOND_TIMERS) {
if (Millisecond_Counter[index] <= now) {
@@ -97,7 +97,7 @@ bool timer_elapsed_seconds(
unsigned index,
uint32_t seconds)
{
return ((timer_milliseconds(index)/1000) >= seconds);
return ((timer_milliseconds(index) / 1000) >= seconds);
}
/*************************************************************************
@@ -109,7 +109,7 @@ bool timer_elapsed_minutes(
unsigned index,
uint32_t minutes)
{
return ((timer_milliseconds(index)/(1000*60)) >= minutes);
return ((timer_milliseconds(index) / (1000 * 60)) >= minutes);
}
/*************************************************************************
@@ -140,7 +140,7 @@ void timer_init(
/* set timer resolution */
if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) {
fprintf(stderr, "Failed to get timer resolution parameters\n");
fprintf(stderr, "Failed to get timer resolution parameters\n");
}
/* configure for 1ms resolution - if possible */
period = min(max(tc.wPeriodMin, 1), tc.wPeriodMax);
+2 -2
View File
@@ -43,8 +43,8 @@
/* Timer Module */
#ifndef MAX_MILLISECOND_TIMERS
#define TIMER_SILENCE 0
#define MAX_MILLISECOND_TIMERS 1
#define TIMER_SILENCE 0
#define MAX_MILLISECOND_TIMERS 1
#endif
#ifdef __cplusplus