Dirk67:
I'm not that shure,
but I always thought that the Arduino core uses the ARM CMSIS syntax / components (?)
which you can find in the directory
..\packages\arduino\tools\CMSIS\4.0.0-atmel\Device\ATMEL\samd21\include\component
you can find "port.h" there for example,
containing the unions, typedefs, an structs for all that stuff:
/* -------- PORT_OUTCLR : (PORT Offset: 0x14) (R/W 32) GROUP Data Output Value Clear -------- */
typedef union {
struct {
uint32_t OUTCLR:32; /*!< bit: 0..31 Port Data Output Value Clear /
} bit; /!< Structure used for bit access /
uint32_t reg; /!< Type used for register access */
} PORT_OUTCLR_Type;
and then mapped together within a "PortGroup" structure:
typedef struct {
__IO PORT_DIR_Type DIR; /< \brief Offset: 0x00 (R/W 32) Data Direction */
__IO PORT_DIRCLR_Type DIRCLR; /< \brief Offset: 0x04 (R/W 32) Data Direction Clear */
__IO PORT_DIRSET_Type DIRSET; /< \brief Offset: 0x08 (R/W 32) Data Direction Set */
__IO PORT_DIRTGL_Type DIRTGL; /< \brief Offset: 0x0C (R/W 32) Data Direction Toggle */
__IO PORT_OUT_Type OUT; /< \brief Offset: 0x10 (R/W 32) Data Output Value */
__IO PORT_OUTCLR_Type OUTCLR; /< \brief Offset: 0x14 (R/W 32) Data Output Value Clear */
__IO PORT_OUTSET_Type OUTSET; /< \brief Offset: 0x18 (R/W 32) Data Output Value Set */
__IO PORT_OUTTGL_Type OUTTGL; /< \brief Offset: 0x1C (R/W 32) Data Output Value Toggle */
__I PORT_IN_Type IN; /< \brief Offset: 0x20 (R/ 32) Data Input Value */
__IO PORT_CTRL_Type CTRL; /< \brief Offset: 0x24 (R/W 32) Control */
__O PORT_WRCONFIG_Type WRCONFIG; /< \brief Offset: 0x28 ( /W 32) Write Configuration */
RoReg8 Reserved1[0x4];
__IO PORT_PMUX_Type PMUX[16]; /< \brief Offset: 0x30 (R/W 8) Peripheral Multiplexing n */
__IO PORT_PINCFG_Type PINCFG[32]; /**< \brief Offset: 0x40 (R/W 8) Pin Configuration n */
RoReg8 Reserved2[0x20];
} PortGroup;
I think the PORT itself (just an address) ist defined in
..\packages\arduino\tools\CMSIS\4.0.0-atmel\Device\ATMEL\samd21\include\samd21g18a.h
[...]
#define PORT (0x41004400U) /< \brief (PORT) APB Base Address */
#define PORT_IOBUS (0x60000000U) /< \brief (PORT) IOBUS Base Address */
[...]
maybe to use the faster IOBUS-system, you can just use the other base address ?
(but maybe you need another startup-code then ? I don't know...)
(but this will have other disadvantages in some (non-) deterministic behaviour, I think...)
---------------------
the pin discriptions (g_APinDescription[] - array) is found in
..\packages\arduino\hardware\samd\1.6.0\variants\arduino_zero\variant.cpp
I think...
The type-definition itself for g_APinDescription[] is found in:
..\packages\arduino\hardware\samd\1.6.0\cores\arduino\WVariant.h
/* Types used for the table below /
typedef struct _PinDescription
{
EPortType ulPort ;
uint32_t ulPin ;
EPioType ulPinType ;
uint32_t ulPinAttribute ;
EAnalogChannel ulADCChannelNumber ; / ADC Channel number in the SAM device */
EPWMChannel ulPWMChannel ;
ETCChannel ulTCChannel ;
EExt_Interrupts ulExtInt ;
} PinDescription ;
/* Pins table to be instantiated into variant.cpp */
extern const PinDescription g_APinDescription[] ;
So then if someone can explain from Atmel samd21 at Page 382, how it works a little bit more so we can get the little Pin direct...
22.6.2 Basic Operation
22.6.2.1 Initialization
After reset, all standard-function device I/O pins are connected to the PORT with outputs tri-stated and input buffers
disabled, even if no clocks are running. Specific pins, such as the ones used for connection to a debugger, may be
configured differently, as required by their special function.
Each I/O pin y can be configured and accessed by reading or writing PORT registers. Because PORT registers are
grouped into sets of registers for each group of up to 32 pins, the base address of the register set for pin y is at byte
address PORT + (y/32) * 0x80. (y%32) will be used as the index within each register of that register set.
To use pin y as an output, configure it as output by writing the (y%32) bit in the DIR register to one. To avoid disturbing
the configuration of other pins in that group, this can also be done by writing the (y%32) bit in the DIRSET register to one.
The desired output value can be set by writing the (y%32) bit to that value in register OUT.
Similarly, writing one to a bit in Data Output Value Set (OUTSET) register will set the corresponding bit in Data Output
Value (OUT) register to one. Writing one to a bit in Data Output Value Clear (OUTCLR) register will set the corresponding
bit in Data Output Value (OUT) register to zero. Writing one to a bit in Data Output Value Toggle (OUTTGL) register will
toggle the corresponding bit in Data Output Value (OUT) register.
To use pin y as an input, configure it as input by writing the (y%32) bit in the DIR register to zero. To avoid disturbing the
configuration of other pins in that group, this can also be done by writing the (y%32) bit in DIRCLR register to one. The
desired input value can be read from the (y%32) bit in register IN as soon as the INEN bit in the Pin Configuration register
(PINCFGy) is written to one. Refer to “I/O Multiplexing and Considerations” on page 20 for details on pin configuration.
...gives me headache this damm Basic operations.
I try some direct Pin operations on the same base Dirk67 posted for the Onewire lib, discused there