1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-01 23:29:28 +01:00

Fix syntax error on wiring_analog

This commit is contained in:
Cristian Maglie 2011-11-21 13:15:00 +01:00
parent f77fcec4e9
commit 1c9738e3db

View File

@ -18,27 +18,28 @@
//#include "wiring_private.h"
#include "Arduino.h"
#include "variant.h"
#ifdef __cplusplus
extern "C" {
#endif
eAnalogReference analog_reference = AR_DEFAULT;
void analogReference( eAnalogReference ulMode )
{
void analogReference(eAnalogReference ulMode) {
analog_reference = ulMode;
}
uint32_t analogRead( uint32_t ulPin )
{
uint32_t analogRead(uint32_t ulPin) {
uint32_t ulValue = 0;
uint32_t ulChannel;
if (ulPin < A0)
ulPin += A0;
ulChannel = g_APinDescription[ulPin].ulAnalogChannel;
#if defined SAM3U4E
#if defined __SAM3U4E__
switch ( ulChannel )
{
// Handling ADC 10 bits channels
@ -57,7 +58,7 @@ uint32_t analogRead( uint32_t ulPin )
adc_start( ADC );
// Wait for end of conversion
while ( adc_get_status( ADC ) & (1<<ulChannel) ) == 0 ) ;
while ((adc_get_status(ADC) & (1<<ulChannel)) == 0);
// Read the value
ulValue=adc_get_value( ADC, ulChannel );
@ -85,7 +86,7 @@ uint32_t analogRead( uint32_t ulPin )
adc12_start( ADC12B );
// Wait for end of conversion
while ( adc12_get_status( ADC12B ) & (1<<(ulChannel-ADC8)) ) == 0 ) ;
while ((adc12_get_status(ADC12B) & (1<<(ulChannel-ADC8))) == 0);
// Read the value
ulValue=adc12_get_value( ADC12B, ulChannel-ADC8 );
@ -111,47 +112,25 @@ uint32_t analogRead( uint32_t ulPin )
// hardware support. These are defined in the appropriate
// pins_*.c file. For the rest of the pins, we default
// to digital output.
void analogWrite( uint32_t ulPin, uint32_t ulValue )
{
void analogWrite(uint32_t ulPin, uint32_t ulValue) {
pinMode(ulPin, OUTPUT);
if ( ulValue == 0 )
{
if (ulValue == 0) {
digitalWrite(ulPin, LOW);
}
else
{
if ( ulValue == 255 )
{
} else if (ulValue == 255) {
digitalWrite(ulPin, HIGH);
}
else
{
if ( (g_APinDescription[ulPin].ulPinAttribute && PIN_ATTR_PWM) == PIN_ATTR_PWM )
{
} else if ((g_APinDescription[ulPin].ulPinAttribute && PIN_ATTR_PWM)
== PIN_ATTR_PWM) {
// Setup PWM for this pin
}
else
{
if ( (g_APinDescription[ulPin].ulPinAttribute && PIN_ATTR_TIMER) == PIN_ATTR_TIMER )
{
} else if ((g_APinDescription[ulPin].ulPinAttribute && PIN_ATTR_TIMER)
== PIN_ATTR_TIMER) {
// Setup Timer for this pin
}
else
{
if ( ulValue < 128 )
{
} else if (ulValue < 128) {
digitalWrite(ulPin, LOW);
}
else
{
} else {
digitalWrite(ulPin, HIGH);
}
}
}
}
}
}
#ifdef __cplusplus
}