mirror of
https://github.com/esp8266/Arduino.git
synced 2025-12-01 17:57:53 +03:00
[sam] fixing due variant issue and preparing work on analog
This commit is contained in:
@@ -78,7 +78,8 @@ typedef void (*voidFuncPtr)( void ) ;
|
||||
/* Definitions and types for pins */
|
||||
typedef enum _EAnalogChannel
|
||||
{
|
||||
ADC0,
|
||||
NONE=-1,
|
||||
ADC0=0,
|
||||
ADC1,
|
||||
ADC2,
|
||||
ADC3,
|
||||
@@ -119,6 +120,7 @@ typedef struct _PinDescription
|
||||
EAnalogChannel ulAnalogChannel ;
|
||||
} PinDescription ;
|
||||
|
||||
/* Pins table to be instanciated into variant.cpp */
|
||||
extern const PinDescription g_APinDescription[] ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -31,17 +31,14 @@
|
||||
#endif
|
||||
|
||||
|
||||
uint8_t analog_reference = DEFAULT;
|
||||
eAnalogReference analog_reference = AR_DEFAULT ;
|
||||
|
||||
void analogReference(uint8_t mode)
|
||||
void analogReference( eAnalogReference ulMode )
|
||||
{
|
||||
// can't actually set the register here because the default setting
|
||||
// will connect AVCC and the AREF pin, which would cause a short if
|
||||
// there's something connected to AREF.
|
||||
analog_reference = mode;
|
||||
analog_reference = ulMode ;
|
||||
}
|
||||
|
||||
int analogRead(uint8_t pin)
|
||||
uint32_t analogRead( uint32_t ulPin )
|
||||
{
|
||||
uint8_t low, high;
|
||||
|
||||
@@ -94,7 +91,7 @@ int analogRead(uint8_t pin)
|
||||
// hardware support. These are defined in the appropriate
|
||||
// pins_*.c file. For the rest of the pins, we default
|
||||
// to digital output.
|
||||
void analogWrite(uint8_t pin, int val)
|
||||
void analogWrite( uint32_t ulPin, uint32_t ulValue )
|
||||
{
|
||||
// We need to make sure the PWM output is enabled for those pins
|
||||
// that support it, as we turn it off when digitally reading or
|
||||
|
||||
@@ -8,19 +8,35 @@
|
||||
#endif
|
||||
|
||||
/*
|
||||
* \brief
|
||||
* \brief SAM3 products have only one reference for ADC
|
||||
*/
|
||||
extern void analogReference( uint8_t mode ) ;
|
||||
typedef enum _eAnalogReference
|
||||
{
|
||||
AR_DEFAULT,
|
||||
} eAnalogReference ;
|
||||
|
||||
/*
|
||||
* \brief
|
||||
* \brief Configures the reference voltage used for analog input (i.e. the value used as the top of the input range).
|
||||
* This function is kept only for compatibility with existing AVR based API.
|
||||
*
|
||||
* \param ulMmode Should be set to AR_DEFAULT.
|
||||
*/
|
||||
extern void analogWrite( uint8_t, int ) ;
|
||||
extern void analogReference( eAnalogReference ulMode ) ;
|
||||
|
||||
/*
|
||||
* \brief
|
||||
* \brief Writes an analog value (PWM wave) to a pin.
|
||||
*
|
||||
* \param ulPin
|
||||
* \param ulValue
|
||||
*/
|
||||
extern int analogRead( uint8_t ) ;
|
||||
extern void analogWrite( uint32_t ulPin, uint32_t ulValue ) ;
|
||||
|
||||
/*
|
||||
* \brief Reads the value from the specified analog pin.
|
||||
*
|
||||
* \param ulValue
|
||||
*/
|
||||
extern uint32_t analogRead( uint32_t ulPin ) ;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user