generated from zephyrproject-rtos/example-application
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0e4c45
commit 5a0be70
Showing
9 changed files
with
448 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "libopencm3"] | ||
path = libopencm3 | ||
url = https://github.com/libopencm3/libopencm3.git |
Submodule libopencm3
added at
32a169
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
## | ||
## This file is part of the libopencm3 project. | ||
## | ||
## Copyright (C) 2009 Uwe Hermann <[email protected]> | ||
## | ||
## This library is free software: you can redistribute it and/or modify | ||
## it under the terms of the GNU Lesser General Public License as published by | ||
## the Free Software Foundation, either version 3 of the License, or | ||
## (at your option) any later version. | ||
## | ||
## This library is distributed in the hope that it will be useful, | ||
## but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
## GNU Lesser General Public License for more details. | ||
## | ||
## You should have received a copy of the GNU Lesser General Public License | ||
## along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
## | ||
|
||
BINARY = main | ||
CSTD = -std=gnu99 | ||
|
||
LDSCRIPT = nucleo-g030f6.ld | ||
LIBNAME = opencm3_stm32g0 | ||
DEFS += -DSTM32G0 | ||
|
||
FP_FLAGS ?= -msoft-float | ||
ARCH_FLAGS = -mthumb -mcpu=cortex-m0 $(FP_FLAGS) | ||
|
||
################################################################################ | ||
# OpenOCD specific variables | ||
|
||
OOCD ?= openocd | ||
OOCD_INTERFACE ?= stlink | ||
OOCD_TARGET ?= stm32g0x | ||
|
||
################################################################################ | ||
# Black Magic Probe specific variables | ||
# Set the BMP_PORT to a serial port and then BMP is used for flashing | ||
BMP_PORT ?= | ||
|
||
################################################################################ | ||
# texane/stlink specific variables | ||
#STLINK_PORT ?= :4242 | ||
|
||
|
||
include rules.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# README | ||
|
||
This example program sends a message "Pass: n" with increasing number n | ||
from 0 to 200 on USART2 serial line of ST NUCLEO-G031K8 eval board. | ||
|
||
The sending is done using newlib library in a blocking way. | ||
|
||
## Board connections | ||
|
||
| Port | Function | Description | | ||
| ----- | ------------- | --------------------------------- | | ||
| `PA2` | `(USART2_TX)` | TTL serial output `(115200,8,N,1)` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include <libopencm3/stm32/rcc.h> | ||
#include <libopencm3/stm32/gpio.h> | ||
#include <libopencm3/stm32/usart.h> | ||
|
||
#include <stdio.h> | ||
|
||
#define PORT_LED GPIOA | ||
#define PIN_LED1 GPIO5 | ||
#define PIN_LED2 GPIO7 | ||
|
||
void uart_out(char* data); | ||
|
||
static void clock_setup(void) | ||
{ | ||
/* Enable GPIOC clock for LED & USARTs. */ | ||
rcc_set_sysclk_source(RCC_CLOCK_CONFIG_HSI_PLL_64MHZ); | ||
rcc_periph_clock_enable(RCC_GPIOA); | ||
// rcc_periph_clock_enable(RCC_GPIOC); | ||
|
||
/* Enable clocks for USART. */ | ||
// rcc_periph_clock_enable(RCC_USART1); | ||
} | ||
|
||
static void usart_setup(void) | ||
{ | ||
/* Setup USART parameters. */ | ||
usart_set_baudrate(USART1, 115200); | ||
usart_set_databits(USART1, 8); | ||
usart_set_parity(USART1, USART_PARITY_NONE); | ||
usart_set_stopbits(USART1, USART_CR2_STOPBITS_1); | ||
usart_set_mode(USART1, USART_MODE_TX); | ||
usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE); | ||
|
||
/* Finally enable the USART. */ | ||
usart_enable(USART1); | ||
} | ||
|
||
static void gpio_setup(void) | ||
{ | ||
gpio_mode_setup(PORT_LED, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, PIN_LED1 | PIN_LED2); | ||
|
||
// gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9); | ||
|
||
// gpio_set_af(GPIOA, GPIO_AF1, GPIO9); | ||
} | ||
|
||
void uart_out(char* data) { | ||
while(*data) { | ||
usart_send_blocking(USART1, *data++); /* USART2: Send byte. */ | ||
} | ||
} | ||
|
||
int main(void) | ||
{ | ||
int i = 0; | ||
// char buf[256]; | ||
|
||
clock_setup(); | ||
gpio_setup(); | ||
// usart_setup(); | ||
// sprintf(buf, "Hello world\r\n"); | ||
// uart_out(buf); | ||
|
||
while(1) { | ||
gpio_set(PORT_LED, PIN_LED1 | PIN_LED2); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* This file is part of the libopencm3 project. | ||
* | ||
* Copyright (C) 2009 Uwe Hermann <[email protected]> | ||
* Copyright (C) 2011 Stephen Caudle <[email protected]> | ||
* | ||
* This library is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/* Linker script for ST NUCLEO-G030F6 (STM32G030F6, 32K flash, 8K RAM). */ | ||
|
||
/* Define memory regions. */ | ||
MEMORY | ||
{ | ||
rom (rx) : ORIGIN = 0x08000000, LENGTH = 32K | ||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K | ||
} | ||
|
||
/* Include the common ld script. */ | ||
INCLUDE cortex-m-generic.ld | ||
|
Oops, something went wrong.