Skip to content

Commit b82783f

Browse files
Apollo3: Implement ADC
1 parent 7fd6fdd commit b82783f

File tree

15 files changed

+274
-15
lines changed

15 files changed

+274
-15
lines changed

hal/include/hal/spi_api.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,14 @@ int spi_master_write(spi_t *obj, int value);
276276
*
277277
* The total number of bytes sent and received will be the maximum of
278278
* tx_length and rx_length. The bytes written will be padded with the
279-
* value 0xff.
279+
* write fill value.
280280
*
281281
* Note: Even if the word size / bits per frame is not 8, \c rx_length and \c tx_length
282282
* still give lengths in bytes of input data, not numbers of words.
283+
*
284+
* Note: If \c tx_rx_buffers_equal_length is true in the capabilities structure, then either \c rx_length and \c tx_length
285+
* must be the same, or one of them will be zero. If this is not the case than the HAL implementation should
286+
* return an error.
283287
*
284288
* @param[in] obj The SPI peripheral to use for sending
285289
* @param[in] tx_buffer Pointer to the byte-array of data to write to the device
@@ -432,7 +436,7 @@ const PinMap *spi_slave_cs_pinmap(void);
432436
* @note On MCUs with a data cache, the return value is used to determine if a cache invalidation needs to be done
433437
* after the transfer is complete. If this function returns true, the driver layer will cache invalidate the Rx buffer under
434438
* the assumption that the data needs to be re-read from main memory. Be careful, because if the read was not actually
435-
* done by DMA, and the rx data is in the CPU cache, this invalidation will corrupt it.
439+
* done by DMA, and the rx data is in the CPU cache and NOT main memory, this invalidation will corrupt it.
436440
*
437441
* @note The application layer will always acquire the SPI peripheral first before calling this, including setting the frequency and the bit width. So,
438442
* the \c bit_width argument will never be different from the SPI's currently set bit width, and can actually be ignored.

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ target_sources(mbed-apollo3
5050
device/spi_api.c
5151
device/us_ticker.c
5252
device/itm_api.c
53+
device/analogin_api.c
5354

5455
sdk/CMSIS/AmbiqMicro/Source/system_apollo3.c
5556

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TARGET_SFE_ARTEMIS/PinNames.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ typedef enum
128128
SERIAL1_TX = IO_24,
129129
SERIAL1_RX = IO_25,
130130

131+
// Not a real pin on the device, but can be passed to AnalogIn to read the internal temperature sensor
132+
ADC_TEMP = 0x10000,
133+
131134
// Not connected
132135
NC = NC_VAL
133136
} PinName;

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TARGET_SFE_ARTEMIS_ATP/PinNames.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ typedef enum
164164
SERIAL1_TX = D24,
165165
SERIAL1_RX = D25,
166166

167+
// Not a real pin on the device, but can be passed to AnalogIn to read the internal temperature sensor
168+
ADC_TEMP = 0x10000,
169+
167170
// Not connected
168171
NC = NC_VAL
169172
} PinName;

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TARGET_SFE_ARTEMIS_DK/PinNames.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ typedef enum
134134
CONSOLE_TX = SERIAL_TX,
135135
CONSOLE_RX = SERIAL_RX,
136136

137+
// Not a real pin on the device, but can be passed to AnalogIn to read the internal temperature sensor
138+
ADC_TEMP = 0x10000,
139+
137140
// Not connected
138141
NC = NC_VAL
139142
} PinName;

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TARGET_SFE_ARTEMIS_MODULE/PinNames.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ typedef enum
9797
CONSOLE_TX = SERIAL_TX,
9898
CONSOLE_RX = SERIAL_RX,
9999

100+
// Not a real pin on the device, but can be passed to AnalogIn to read the internal temperature sensor
101+
ADC_TEMP = 0x10000,
102+
100103
// Not connected
101104
NC = NC_VAL
102105
} PinName;

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TARGET_SFE_ARTEMIS_NANO/PinNames.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ typedef enum
130130
SERIAL1_TX = D9,
131131
SERIAL1_RX = D10,
132132

133+
// Not a real pin on the device, but can be passed to AnalogIn to read the internal temperature sensor
134+
ADC_TEMP = 0x10000,
135+
133136
// Not connected
134137
NC = NC_VAL
135138
} PinName;

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TARGET_SFE_ARTEMIS_THING_PLUS/PinNames.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ typedef enum
137137
SERIAL1_TX = D1,
138138
SERIAL1_RX = D0,
139139

140+
// Not a real pin on the device, but can be passed to AnalogIn to read the internal temperature sensor
141+
ADC_TEMP = 0x10000,
142+
140143
// Not connected
141144
NC = NC_VAL
142145
} PinName;

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralNames.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ typedef enum {
4646
IOM_ANY
4747
} IOMName;
4848

49+
// Each IOM can be used as an SPI
50+
#define DEVICE_SPI_COUNT 6
51+
4952
typedef IOMName SPIName;
5053
typedef IOMName I2CName;
5154

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralPins.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,27 @@
1717
#include "PeripheralPins.h"
1818
#include "PeripheralPinConfigs.h"
1919

20+
#include "am_hal_adc.h"
21+
#include "objects.h"
22+
2023
/************RTC***************/
2124
const PinMap PinMap_RTC[] = {
2225
{NC, 0, 0},
2326
};
2427

2528
/************ADC***************/
2629
const PinMap PinMap_ADC[] = {
30+
{11, ADC0_2, AM_HAL_PIN_11_ADCSE2},
31+
{12, ADC0_9, AM_HAL_PIN_12_ADCD0NSE9},
32+
{13, ADC0_8, AM_HAL_PIN_13_ADCD0PSE8},
33+
{16, ADC0_0, AM_HAL_PIN_16_ADCSE0},
34+
{29, ADC0_1, AM_HAL_PIN_29_ADCSE1},
35+
{31, ADC0_3, AM_HAL_PIN_31_ADCSE3},
36+
{32, ADC0_4, AM_HAL_PIN_32_ADCSE4},
37+
{33, ADC0_5, AM_HAL_PIN_33_ADCSE5},
38+
{34, ADC0_6, AM_HAL_PIN_34_ADCSE6},
39+
{35, ADC0_7, AM_HAL_PIN_35_ADCSE7},
40+
{ADC_TEMP, ADC0_TEMP, 0},
2741
{NC, NC, 0}
2842
};
2943

0 commit comments

Comments
 (0)