Skip to content

Commit 65a9916

Browse files
author
Nathan Seidle
committed
Merge branch 'master' into PDM
2 parents 333a32e + 5958591 commit 65a9916

File tree

8 files changed

+119
-106
lines changed

8 files changed

+119
-106
lines changed

boards.txt

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -221,39 +221,39 @@ edge.menu.loader.sparkfun_svl.build.ldscript={build.variant.path}/linker_scripts
221221

222222
###############################################################
223223

224-
edgeV2.name=SparkFun Edge V2
225-
edgeV2.build.variant=SparkFun_Edge_V2
226-
edgeV2.build.board=SFE_EDGE_V2
227-
edgeV2.upload.maximum_size=960000
228-
edgeV2.upload.sbl_baud=115200
229-
edgeV2.build.arch=APOLLO3
230-
edgeV2.build.mcu=cortex-m4
231-
edgeV2.build.f_cpu=48000000L
232-
edgeV2.build.core=arduino
233-
edgeV2.build.includes=-I{build.variant.path}/config
234-
edgeV2.build.extra_flags=-DPART_apollo3 -DAM_PACKAGE_BGA -DAM_PART_APOLLO3
235-
edgeV2.build.ldscript={build.variant.path}/linker_scripts/gcc/flash_with_bootloader.ld
236-
edgeV2.build.defs=
237-
edgeV2.build.libs=
238-
edgeV2.menu.svl_baud.921600=921600
239-
edgeV2.menu.svl_baud.460800=460800
240-
edgeV2.menu.svl_baud.230400=230400
241-
edgeV2.menu.svl_baud.115200=115200
242-
edgeV2.menu.svl_baud.57600=57600
243-
edgeV2.menu.loader.sparkfun_svl=SparkFun Variable Loader (Recommended)
244-
edgeV2.menu.loader.ambiq_sbl=Ambiq Secure Bootloader (Advanced)
245-
246-
edgeV2.menu.svl_baud.57600.upload.svl_baud=57600
247-
edgeV2.menu.svl_baud.115200.upload.svl_baud=115200
248-
edgeV2.menu.svl_baud.230400.upload.svl_baud=230400
249-
edgeV2.menu.svl_baud.460800.upload.svl_baud=460800
250-
edgeV2.menu.svl_baud.921600.upload.svl_baud=921600
251-
252-
edgeV2.menu.loader.ambiq_sbl.upload.tool=ambiq_bin2board
253-
edgeV2.menu.loader.ambiq_sbl.build.ldscript={build.variant.path}/linker_scripts/gcc/ambiq_sbl_app.ld
254-
255-
edgeV2.menu.loader.sparkfun_svl.upload.tool=artemis_svl
256-
edgeV2.menu.loader.sparkfun_svl.build.ldscript={build.variant.path}/linker_scripts/gcc/artemis_sbl_svl_app.ld
224+
edge2.name=SparkFun Edge2
225+
edge2.build.variant=SparkFun_Edge2
226+
edge2.build.board=SFE_EDGE2
227+
edge2.upload.maximum_size=960000
228+
edge2.upload.sbl_baud=115200
229+
edge2.build.arch=APOLLO3
230+
edge2.build.mcu=cortex-m4
231+
edge2.build.f_cpu=48000000L
232+
edge2.build.core=arduino
233+
edge2.build.includes=-I{build.variant.path}/config
234+
edge2.build.extra_flags=-DPART_apollo3 -DAM_PACKAGE_BGA -DAM_PART_APOLLO3
235+
edge2.build.ldscript={build.variant.path}/linker_scripts/gcc/flash_with_bootloader.ld
236+
edge2.build.defs=
237+
edge2.build.libs=
238+
edge2.menu.svl_baud.921600=921600
239+
edge2.menu.svl_baud.460800=460800
240+
edge2.menu.svl_baud.230400=230400
241+
edge2.menu.svl_baud.115200=115200
242+
edge2.menu.svl_baud.57600=57600
243+
edge2.menu.loader.sparkfun_svl=SparkFun Variable Loader (Recommended)
244+
edge2.menu.loader.ambiq_sbl=Ambiq Secure Bootloader (Advanced)
245+
246+
edge2.menu.svl_baud.57600.upload.svl_baud=57600
247+
edge2.menu.svl_baud.115200.upload.svl_baud=115200
248+
edge2.menu.svl_baud.230400.upload.svl_baud=230400
249+
edge2.menu.svl_baud.460800.upload.svl_baud=460800
250+
edge2.menu.svl_baud.921600.upload.svl_baud=921600
251+
252+
edge2.menu.loader.ambiq_sbl.upload.tool=ambiq_bin2board
253+
edge2.menu.loader.ambiq_sbl.build.ldscript={build.variant.path}/linker_scripts/gcc/ambiq_sbl_app.ld
254+
255+
edge2.menu.loader.sparkfun_svl.upload.tool=artemis_svl
256+
edge2.menu.loader.sparkfun_svl.build.ldscript={build.variant.path}/linker_scripts/gcc/artemis_sbl_svl_app.ld
257257

258258
###############################################################
259259

cores/arduino/ard_sup/analog/ap3_analog.cpp

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,13 @@ void ap3_pwm_wait_for_pulse(uint32_t timer, uint32_t segment, uint32_t output, u
415415

416416
// Get the compare value
417417
cmpr0 = ((uint32_t)(*(pui32CompareReg)) & 0x0000FFFF);
418-
419-
// Wait for the timer value to be less than the compare value so that it is safe to change
420-
ctimer_val = am_hal_ctimer_read( timer, segment);
421-
while( (ctimer_val + 0) > cmpr0 ){
418+
419+
if( cmpr0 ){ // Only wait when cmpr0 is greater than 0 to avoid an infinite while loop
420+
// Wait for the timer value to be less than the compare value so that it is safe to change
422421
ctimer_val = am_hal_ctimer_read( timer, segment);
422+
while( (ctimer_val + 0) >= cmpr0 ){
423+
ctimer_val = am_hal_ctimer_read( timer, segment);
424+
}
423425
}
424426
}
425427
}
@@ -526,13 +528,16 @@ ap3_err_t ap3_pwm_output(uint8_t pin, uint32_t th, uint32_t fw, uint32_t clk)
526528
}
527529

528530
// Test for AM_HAL_CTIMER_OUTPUT_FORCE0 or AM_HAL_CTIMER_OUTPUT_FORCE1
531+
bool set_periods = true;
529532
if ((th == 0) || (fw == 0))
530533
{
531534
output = AM_HAL_CTIMER_OUTPUT_FORCE0;
535+
set_periods = false; // disable setting periods when going into a forced mode
532536
}
533537
else if (th == fw)
534538
{
535539
output = AM_HAL_CTIMER_OUTPUT_FORCE1;
540+
set_periods = false; // disable setting periods when going into a forced mode
536541
}
537542

538543
// Wait until after high pulse to change the state (avoids inversion)
@@ -551,31 +556,33 @@ ap3_err_t ap3_pwm_output(uint8_t pin, uint32_t th, uint32_t fw, uint32_t clk)
551556
// (AM_HAL_CTIMER_FN_PWM_REPEAT | AP3_ANALOG_CLK | AM_HAL_CTIMER_INT_ENABLE) );
552557
(AM_HAL_CTIMER_FN_PWM_REPEAT | clk));
553558

554-
// If this pad uses secondary output:
555-
if (output == AM_HAL_CTIMER_OUTPUT_SECONDARY)
556-
{
557-
// Need to explicitly enable compare registers 2/3
558-
uint32_t *pui32ConfigReg = NULL;
559-
pui32ConfigReg = (uint32_t *)CTIMERADDRn(CTIMER, timer, AUX0);
560-
uint32_t ui32WriteVal = AM_REGVAL(pui32ConfigReg);
561-
uint32_t ui32ConfigVal = (1 << CTIMER_AUX0_TMRA0EN23_Pos); // using CTIMER_AUX0_TMRA0EN23_Pos because for now this number is common to all CTimer instances
562-
if (segment == AM_HAL_CTIMER_TIMERB)
559+
if(set_periods){
560+
// If this pad uses secondary output:
561+
if (output == AM_HAL_CTIMER_OUTPUT_SECONDARY)
562+
{
563+
// Need to explicitly enable compare registers 2/3
564+
uint32_t *pui32ConfigReg = NULL;
565+
pui32ConfigReg = (uint32_t *)CTIMERADDRn(CTIMER, timer, AUX0);
566+
uint32_t ui32WriteVal = AM_REGVAL(pui32ConfigReg);
567+
uint32_t ui32ConfigVal = (1 << CTIMER_AUX0_TMRA0EN23_Pos); // using CTIMER_AUX0_TMRA0EN23_Pos because for now this number is common to all CTimer instances
568+
if (segment == AM_HAL_CTIMER_TIMERB)
569+
{
570+
ui32ConfigVal = ((ui32ConfigVal & 0xFFFF) << 16);
571+
}
572+
ui32WriteVal = (ui32WriteVal & ~(segment)) | ui32ConfigVal;
573+
AM_REGVAL(pui32ConfigReg) = ui32WriteVal;
574+
575+
// then set the duty cycle with the 'aux' function
576+
am_hal_ctimer_aux_period_set(timer, segment, fw, th);
577+
}
578+
else
563579
{
564-
ui32ConfigVal = ((ui32ConfigVal & 0xFFFF) << 16);
580+
// Otherwise simply set the primary duty cycle
581+
am_hal_ctimer_period_set(timer, segment, fw, th);
565582
}
566-
ui32WriteVal = (ui32WriteVal & ~(segment)) | ui32ConfigVal;
567-
AM_REGVAL(pui32ConfigReg) = ui32WriteVal;
568583

569-
// then set the duty cycle with the 'aux' function
570-
am_hal_ctimer_aux_period_set(timer, segment, fw, th);
584+
am_hal_ctimer_start(timer, segment); // Start the timer only when there are periods to compare to
571585
}
572-
else
573-
{
574-
// Otherwise simply set the primary duty cycle
575-
am_hal_ctimer_period_set(timer, segment, fw, th);
576-
}
577-
578-
am_hal_ctimer_start(timer, segment);
579586

580587
return AP3_OK;
581588
}
@@ -594,17 +601,17 @@ ap3_err_t analogWriteResolution(uint8_t res)
594601
ap3_err_t analogWrite(uint8_t pin, uint32_t val)
595602
{
596603
// Determine the high time based on input value and the current resolution setting
597-
uint32_t fw = 0xFFFF; // Choose the frame width in clock periods (32767 -> ~ 180 Hz)
598-
if (val == ((0x01 << _analogWriteBits) - 1))
604+
uint32_t clk = AM_HAL_CTIMER_HFRC_12MHZ; // Use an Ambiq HAL provided value to select which clock
605+
uint32_t fw = 0xFFFF; // Choose the frame width in clock periods (32767 -> ~ 180 Hz)
606+
if (val >= ((0x01 << _analogWriteBits) - 1))
599607
{
600608
val = fw; // Enable FORCE1
601609
}
602610
else
603611
{
604-
val <<= (16 - _analogWriteBits); // Shift over the value to fill available resolution
612+
val <<= (16 - _analogWriteBits); // Shift over the value to fill available resolution
605613
}
606-
uint32_t clk = AM_HAL_CTIMER_HFRC_12MHZ; // Use an Ambiq HAL provided value to select which clock
607-
614+
608615
return ap3_pwm_output(pin, val, fw, clk);
609616
}
610617

variants/SparkFun_Edge_V2/config/variant.cpp renamed to variants/SparkFun_Edge2/config/variant.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,53 +28,53 @@ const ap3_gpio_pad_t ap3_variant_pinmap[AP3_VARIANT_NUM_PINS] = {
2828
AP3_GPIO_PAD_UNUSED,
2929
AP3_GPIO_PAD_UNUSED,
3030
AP3_GPIO_PAD_UNUSED,
31-
4,
3231
AP3_GPIO_PAD_UNUSED,
33-
6,
34-
7,
32+
5, //Camera D5
33+
6, //Camera D4
34+
7, //Camera PCLK
35+
8, //Camera SCL
36+
9, //Camera SDA
3537
AP3_GPIO_PAD_UNUSED,
38+
11, //Camera D1
39+
12, //Mic CLK
40+
13, //Camera Trig
41+
14, //Camera D0
42+
15, //Camera VSync
43+
16, //GPIO 16
44+
17, //LED Green
45+
18, //LED Blue
46+
19, //LED Red
47+
20, //SWDCK
48+
21, //SWDIO
3649
AP3_GPIO_PAD_UNUSED,
50+
23, //Camera INT
3751
AP3_GPIO_PAD_UNUSED,
38-
11,
39-
12,
40-
13,
41-
14,
42-
15,
43-
16,
44-
17,
45-
18,
46-
19,
47-
20,
48-
21,
49-
22,
50-
23,
51-
24,
52-
25,
53-
26,
54-
27,
55-
28,
56-
29,
52+
25, //Camera D2
53+
26, //Camera MCLK
54+
27, //Camera HSync
55+
28, //Camera D7
56+
29, //Mic DATA
5757
AP3_GPIO_PAD_UNUSED,
58-
31,
59-
32,
60-
33,
61-
34,
62-
35,
58+
31, //GPIO 31
59+
32, //Camera 1.8V Enable
60+
33, //GPIO 33
61+
34, //Camera D3
62+
35, //Camera D6
6363
AP3_GPIO_PAD_UNUSED,
64-
37,
64+
37, //LED Yellow
6565
AP3_GPIO_PAD_UNUSED,
66-
39,
67-
40,
66+
39, //Qwiic SCL
67+
40, //Qwiic SDA
6868
AP3_GPIO_PAD_UNUSED,
69-
42,
70-
43,
71-
44,
72-
45,
69+
42, //Accel SCL
70+
43, //Accel SDA
71+
44, //GPIO 44
72+
45, //GPIO 45
7373
AP3_GPIO_PAD_UNUSED,
7474
AP3_GPIO_PAD_UNUSED,
75-
48,
76-
49,
75+
48, //Boot TX
76+
49, //Boot RX
7777
};
7878

7979
// Uart Definitions
80-
Uart Serial(0, 49, 48);// declares a Uart object called Serial using instance 0 of Apollo3 UART peripherals with RX on pin 49 and TX on pin 48 (note, you specify *pins* not Apollo3 pads. This uses the variant's pin map to determine the Apollo3 pad)
80+
Uart Serial(0, 49, 48); // declares a Uart object called Serial using instance 0 of Apollo3 UART peripherals with RX on pin 49 and TX on pin 48 (note, you specify *pins* not Apollo3 pads. This uses the variant's pin map to determine the Apollo3 pad)

variants/SparkFun_Edge_V2/config/variant.h renamed to variants/SparkFun_Edge2/config/variant.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,31 @@ SOFTWARE.
3030
extern const ap3_gpio_pad_t ap3_variant_pinmap[AP3_VARIANT_NUM_PINS];
3131

3232
// Uart declarations
33-
class Uart; // Forward declaration of Uart
33+
class Uart; // Forward declaration of Uart
3434
extern Uart Serial;
3535

3636
// Wire defines
3737
#define WIRE_INTERFACES_COUNT 3
3838

39-
#define WireQwiic Wire // Giving Wire an alias of "WireQwiic" in case people want to use it
40-
#define AP3_Wire_IOM 4 // Secify that Wire uses IOMaster instance 4
39+
#define WireQwiic Wire // Giving Wire an alias of "WireQwiic" in case people want to use it
40+
#define AP3_Wire_IOM 4 // Secify that Wire uses IOMaster instance 4
4141

4242
#define WireAccel Wire1
4343
#define AP3_Wire1_IOM 3
4444

4545
#define WireCamera Wire2
46-
#define AP3_Wire1_IOM 2
46+
#define AP3_Wire2_IOM 1
4747

4848
// SPI Defines
49-
#define SPI_INTERFACES_COUNT 0 //Edge V2 doesn't have any fully-exposed SPI ports
50-
49+
#define SPI_INTERFACES_COUNT 0 //Edge V2 doesn't have any fully-exposed SPI ports
5150

5251
#define LED_BUILTIN 19
52+
#define LED_GREEN 17
53+
#define LED_BLUE 18
54+
#define LED_RED 19
55+
#define LED_YELLOW 37
56+
57+
#define MIC_DATA 29
58+
#define MIC_CLOCK 12
5359

5460
#endif // _AP3_VARIANT_H_

0 commit comments

Comments
 (0)