Skip to content

Commit 853b8bf

Browse files
Apollo3: Implement AnalogIn and PwmOut (#476)
* Apollo3: Implement ADC * Start implementing PWM * Map all PWM pins * Initial pwmout_period implementation * Finish PWM driver, start getting PWM and ADC working * PWM passing tests! * Oops remove debug prints * A few fixes
1 parent 7fd6fdd commit 853b8bf

File tree

24 files changed

+760
-34
lines changed

24 files changed

+760
-34
lines changed

cmsis/device/rtos/include/mbed_boot.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include "mbed_toolchain.h"
2121

22+
#include <stdint.h>
23+
2224
#ifdef __cplusplus
2325
extern "C" {
2426
#endif

hal/include/hal/pwmout_api.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ typedef struct pwmout_s pwmout_t;
4242
* * ::pwmout_write sets the output duty-cycle in range <0.0f, 1.0f>
4343
* * ::pwmout_read returns the current float-point output duty-cycle in range <0.0f, 1.0f>
4444
* * ::pwmout_period sets the PWM period specified in seconds, keeping the duty cycle the same
45-
* * ::pwmout_period_ms sets the PWM period specified in miliseconds, keeping the duty cycle the same
45+
* * ::pwmout_period_ms sets the PWM period specified in milliseconds, keeping the duty cycle the same
4646
* * ::pwmout_period_us sets the PWM period specified in microseconds, keeping the duty cycle the same
4747
* * ::pwmout_read_period_us reads the PWM period specified in microseconds
4848
* * ::pwmout_pulsewidth sets the PWM pulsewidth specified in seconds, keeping the period the same
@@ -84,7 +84,11 @@ void pwmout_init_direct(pwmout_t *obj, const PinMap *pinmap);
8484
*/
8585
void pwmout_init(pwmout_t *obj, PinName pin);
8686

87-
/** Deinitialize the pwmout object
87+
/**
88+
* @brief Deinitialize the pwmout object
89+
*
90+
* After this function is called, the PWM output must stop generating edges.
91+
* The logic level is not specified -- it may be left high, low, or tristated.
8892
*
8993
* @param obj The pwmout object
9094
*/

hal/include/hal/spi_api.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,15 @@ 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.
283283
*
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.
287+
*
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
286290
* @param[in] tx_length Number of bytes to write, may be zero
@@ -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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ target_sources(mbed-apollo3
5050
device/spi_api.c
5151
device/us_ticker.c
5252
device/itm_api.c
53+
device/analogin_api.c
54+
device/pwmout_api.c
55+
device/mbed_overrides.c
5356

5457
sdk/CMSIS/AmbiqMicro/Source/system_apollo3.c
5558

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TARGET_SFE_ARTEMIS/PinNames.h

Lines changed: 3 additions & 5 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+
INT_TEMP_SENSOR = 0x10000,
133+
131134
// Not connected
132135
NC = NC_VAL
133136
} PinName;
@@ -140,11 +143,6 @@ typedef enum
140143
#define QWIIC_SCL I2C_SCL
141144
#define QWIIC_SDA I2C_SDA
142145

143-
// SPI bus
144-
#define SPI_SCLK IO_5
145-
#define SPI_MOSI IO_7
146-
#define SPI_MISO IO_6
147-
148146
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
149147
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
150148
#else

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+
INT_TEMP_SENSOR = 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+
INT_TEMP_SENSOR = 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+
INT_TEMP_SENSOR = 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+
INT_TEMP_SENSOR = 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+
INT_TEMP_SENSOR = 0x10000,
142+
140143
// Not connected
141144
NC = NC_VAL
142145
} PinName;

0 commit comments

Comments
 (0)