Skip to content
Snippets Groups Projects
Commit 49d8791d authored by cnlohr's avatar cnlohr
Browse files

Switch blink example to using easy mode

parent 41dbf676
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -6,31 +6,24 @@ 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);
funGpioInitAll();
funPinMode( PD0, GPIO_Speed_10MHz | GPIO_CNF_OUT_PP );
funPinMode( PD4, GPIO_Speed_10MHz | GPIO_CNF_OUT_PP );
funPinMode( PD6, GPIO_Speed_10MHz | GPIO_CNF_OUT_PP );
funPinMode( PC0, GPIO_Speed_10MHz | GPIO_CNF_OUT_PP );
while(1)
{
GPIOD->BSHR = (1<<0) | (1<<4) | (1<<6); // Turn on GPIOs
GPIOC->BSHR = (1<<0);
funDigitalWrite( PD0, FUN_HIGH );
funDigitalWrite( PD4, FUN_HIGH );
funDigitalWrite( PD6, FUN_HIGH );
funDigitalWrite( PC0, FUN_HIGH );
Delay_Ms( 250 );
GPIOD->BSHR = (1<<16) | (1<<(16+4)) | (1<<(16+6)); // Turn off GPIOs
GPIOC->BSHR = (1<<16);
funDigitalWrite( PD0, FUN_LOW );
funDigitalWrite( PD4, FUN_LOW );
funDigitalWrite( PD6, FUN_LOW );
funDigitalWrite( PC0, FUN_LOW );
Delay_Ms( 250 );
}
}
all : flash
TARGET:=blink_raw
include ../../ch32v003fun/ch32v003fun.mk
flash : cv_flash
clean : cv_clean
File added
#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 );
}
}
#ifndef _FUNCONFIG_H
#define _FUNCONFIG_H
#define CH32V003 1
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment