Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

hocarm

🎯
Focusing
View GitHub Profile
View counter.c
int counter;
int counterInc(void) {
return counter ++;
}
View counter.asm
counterInc:
0: f240 0300 movw r3 , #: lower16:counter // r3 = &counter
4: f2c0 0300 movt r3 , #: upper16:counter
8: 6818 ldr r0 , [r3 , #0] // r0 = *r3
a: 1c42 adds r2 , r0 , #1 // r2 = r0 + 1
c: 601a str r2 , [r3 , #0] // *r3 = r2
e: 4740 bx lr // return r0
View GPIO_TypeDef.c
typedef struct
{
volatile uint32_t CRL;
volatile uint32_t CRH;
volatile uint32_t IDR;
volatile uint32_t ODR;
volatile uint32_t BSRR;
volatile uint32_t BRR;
volatile uint32_t LCKR;
} GPIO_TypeDef;
View define_io.c
#define PERIPH_BASE (( uint32_t)0x40000000)
#define APB2PERIPH_BASE (PERIPH_BASE + 0x10000)
#define GPIOA_BASE (APB2PERIPH_BASE + 0x0800)
#define GPIOA (( GPIO_TypeDef *) GPIOA_BASE)
View ReadInputData.c
uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx) {
return (( uint16_t)GPIOx ->IDR);
}
View GPIO_Func.c
void GPIO_Init(GPIO_TypeDef* GPIOx ,
GPIO_InitTypeDef* GPIO_InitStruct);
uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx ,
uint16_t GPIO_Pin);
uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx ,
uint16_t GPIO_Pin);
uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
void GPIO_SetBits(GPIO_TypeDef* GPIOx , uint16_t GPIO_Pin);
void GPIO_ResetBits(GPIO_TypeDef* GPIOx , uint16_t GPIO_Pin);
View GPIO_wtLib.c
#include <stm32f10x.h>
int main(void) {
int n = 0;
int button;
/* Enable the GPIOA (bit 2) and GPIOC (bit 4) */
/* See 6.3.7 in stm32f100x reference manual */
RCC ->APB2ENR |= 0x10 | 0x04;
/* Set GPIOC Pin 8 and Pin 9 to outputs */
/* 7.2.2 in stm32f100x reference manual */
GPIOC ->CRH = 0x11;
View Blink_Light.c
View Blink_Light_1.c
View Blink_Light_2.c