Skip to content

Commit

Permalink
tracie test program (upload sam)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaruwanS committed May 11, 2024
1 parent 35178d8 commit b8914fe
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"C_Cpp.errorSquiggles": "Disabled"
}
40 changes: 40 additions & 0 deletions backups/mini.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"build": {
"core": "stm32",
"cpu": "cortex-m4",
"extra_flags": "-DSTM32WB -DSTM32WB55xx",
"f_cpu": "64000000L",
"mcu": "stm32wb55rg",
"product_line": "STM32WB55xx"
},
"connectivity": [
"bluetooth"
],
"debug": {
"default_tools": [
"stlink"
],
"openocd_target": "stm32wbx",
"jlink_device": "STM32WB55xx",
"onboard_tools": [
"stlink"
]
},
"frameworks": [
"arduino"
],
"name": "MRAS mini",
"upload": {
"maximum_ram_size": 262144,
"maximum_size": 1048576,
"protocol": "stlink",
"protocols": [
"jlink",
"cmsis-dap",
"stlink",
"blackmagic"
]
},
"url": "https://mras.sunride.space/",
"vendor": "Sunride Rocketry"
}
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
[env:nucleo_wb55rg_p]
platform = ststm32
board = nucleo_wb55rg_p
framework = arduino
framework = arduino
73 changes: 62 additions & 11 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,69 @@
#include <Arduino.h>
#include "Arduino.h"

// put function declarations here:
int myFunction(int, int);
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

void setup() {
// put your setup code here, to run once:
int result = myFunction(2, 3);
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSE
|RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
RCC_OscInitStruct.PLL.PLLN = 32;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}

/** Configure the SYSCLKSource, HCLK, PCLK1 and PCLK2 clocks dividers
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK4|RCC_CLOCKTYPE_HCLK2
|RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.AHBCLK2Divider = RCC_SYSCLK_DIV2;
RCC_ClkInitStruct.AHBCLK4Divider = RCC_SYSCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
{
Error_Handler();
}

/** Enable MSI Auto calibration
*/
HAL_RCCEx_EnableMSIPLLMode();
}

void loop() {
// put your main code here, to run repeatedly:
void setup() {
pinMode(PA2, OUTPUT);
pinMode(PA10, OUTPUT);
return;
}

// put function definitions here:
int myFunction(int x, int y) {
return x + y;
void loop() {
digitalWrite(PA2, HIGH); // Turn the LED on
tone(PA_10, 500, 1000);
delay(3000); // Wait for 3 seconds
digitalWrite(PA2, LOW); // Turn the LED off
delay(3000); // Wait for 3 seconds
}

0 comments on commit b8914fe

Please sign in to comment.