-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch blink example to using easy mode
- Loading branch information
Showing
6 changed files
with
67 additions
and
21 deletions.
There are no files selected for viewing
Binary file not shown.
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,10 @@ | ||
all : flash | ||
|
||
TARGET:=blink_raw | ||
|
||
include ../../ch32v003fun/ch32v003fun.mk | ||
|
||
flash : cv_flash | ||
clean : cv_clean | ||
|
||
|
Binary file not shown.
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,36 @@ | ||
#include "ch32v003fun.h" | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
SystemInit(); | ||
|
||
// Enable GPIOs | ||
RCC->APB2PCENR |= RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOC; | ||
|
||
// GPIO D0 Push-Pull | ||
GPIOD->CFGLR &= ~(0xf<<(4*0)); | ||
GPIOD->CFGLR |= (GPIO_Speed_10MHz | GPIO_CNF_OUT_PP)<<(4*0); | ||
|
||
// GPIO D4 Push-Pull | ||
GPIOD->CFGLR &= ~(0xf<<(4*4)); | ||
GPIOD->CFGLR |= (GPIO_Speed_10MHz | GPIO_CNF_OUT_PP)<<(4*4); | ||
|
||
// GPIO D6 Push-Pull | ||
GPIOD->CFGLR &= ~(0xf<<(4*6)); | ||
GPIOD->CFGLR |= (GPIO_Speed_10MHz | GPIO_CNF_OUT_PP)<<(4*6); | ||
|
||
// GPIO C0 Push-Pull | ||
GPIOC->CFGLR &= ~(0xf<<(4*0)); | ||
GPIOC->CFGLR |= (GPIO_Speed_10MHz | GPIO_CNF_OUT_PP)<<(4*0); | ||
|
||
while(1) | ||
{ | ||
GPIOD->BSHR = (1<<0) | (1<<4) | (1<<6); // Turn on GPIOs | ||
GPIOC->BSHR = (1<<0); | ||
Delay_Ms( 250 ); | ||
GPIOD->BSHR = (1<<16) | (1<<(16+4)) | (1<<(16+6)); // Turn off GPIOs | ||
GPIOC->BSHR = (1<<16); | ||
Delay_Ms( 250 ); | ||
} | ||
} |
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,7 @@ | ||
#ifndef _FUNCONFIG_H | ||
#define _FUNCONFIG_H | ||
|
||
#define CH32V003 1 | ||
|
||
#endif | ||
|