aboutsummaryrefslogtreecommitdiff
path: root/test1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test1.cpp')
-rw-r--r--test1.cpp101
1 files changed, 19 insertions, 82 deletions
diff --git a/test1.cpp b/test1.cpp
index 89e859f..57149c3 100644
--- a/test1.cpp
+++ b/test1.cpp
@@ -5,15 +5,15 @@
#include <stm32f10x_gpio.h>
#include <stddef.h>
+int init_high();
+
+extern "C" void halt();
+
#include "tmp/printf/printf.h"
#include "stm32f10x_conf.h"
extern "C"
-//__attribute__((naked))
-int main(void);
-
-extern "C"
__attribute__((naked))
void HardFault_Handler_C(uint32_t *hardfault_args);
@@ -46,8 +46,7 @@ void HardFault_Handler_C(uint32_t *hardfault_args) {
hardfault_data->pc = hardfault_args[6];
hardfault_data->psr = hardfault_args[7];
- do {
- } while (1);
+ halt();
}
void send_command(int command, void *message) {
@@ -64,77 +63,21 @@ void send_command(int command, void *message) {
);
}
-//static
-const char *alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n";
-
-extern uint32_t _copy_data_load, _copy_data_store, _copy_data_store_end;
-extern uint32_t _bss_start, _bss_end;
-
size_t strlen(const char *s) {
size_t size = 0;
while (*s++ != '\0') size++;
return size;
}
-void test_command() {
- char msg[100];
-
- tfp_sprintf(msg, "Hello World: c=%c\r\n", 'c');
- size_t len = strlen(msg);
-
- uint32_t message[] = {
- 2,
- (uint32_t) msg,
- len
- };
- send_command(0x05, &message);
-
- tfp_sprintf(msg, "Hello %s\r\n", "World!");
- len = strlen(msg);
-
- uint32_t message3[] = {
- 2,
- (uint32_t) msg,
- len
- };
-
- uint32_t message2[] = {
- 2,
- (uint32_t) alphabet,
- 28
- };
- send_command(0x05, &message2);
-
- send_command(0x05, &message3);
-
- send_command(0x05, &message2);
-}
+int run = 1;
/*
* When we get there the stack pointer is set
*/
int main() {
- // Copy data from flash to ram
- uint32_t *src = &_copy_data_load;
- uint32_t *dest = &_copy_data_store;
- uint32_t *end = &_copy_data_store_end;
-
- while (dest <= end) {
- *dest++ = *src++;
- }
-
- // Clear the BSS segment
- dest = &_bss_start;
- end = &_bss_end;
- while (dest <= end) {
- *dest++ = 0;
- }
-
- test_command();
-
SystemInit();
- SystemCoreClockUpdate();
-// RCC->APB2ENR = RCC_APB2ENR_IOPCEN;
+// SystemCoreClockUpdate();
+
SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk | SCB_SHCSR_MEMFAULTPENDED_Msk | SCB_SHCSR_BUSFAULTENA_Msk;
RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOA, ENABLE);
@@ -146,25 +89,19 @@ int main() {
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOA,
ENABLE);
- if (1) {
- GPIO_InitTypeDef init;
- GPIO_StructInit(&init);
- init.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_Init(GPIOB, &init);
-
- while (1) {
- GPIO_SetBits(GPIOA, GPIO_Pin_All);
- GPIO_SetBits(GPIOB, GPIO_Pin_All);
- GPIO_SetBits(GPIOC, GPIO_Pin_All);
-
-// send_command(0x05, &message);
+ GPIO_InitTypeDef init;
+ GPIO_StructInit(&init);
+ init.GPIO_Mode = GPIO_Mode_Out_PP;
+ GPIO_Init(GPIOB, &init);
- GPIO_ResetBits(GPIOA, GPIO_Pin_All);
- GPIO_ResetBits(GPIOB, GPIO_Pin_All);
- GPIO_ResetBits(GPIOC, GPIO_Pin_All);
+ while (run) {
+// GPIO_SetBits(GPIOA, GPIO_Pin_All);
+ GPIO_SetBits(GPIOB, GPIO_Pin_All);
+// GPIO_SetBits(GPIOC, GPIO_Pin_All);
-// send_command(0x05, &message);
- }
+// GPIO_ResetBits(GPIOA, GPIO_Pin_All);
+ GPIO_ResetBits(GPIOB, GPIO_Pin_All);
+// GPIO_ResetBits(GPIOC, GPIO_Pin_All);
}
return 0;