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
int counter; | |
int counterInc(void) { | |
return counter ++; | |
} |
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
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 |
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
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; |
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
#define PERIPH_BASE (( uint32_t)0x40000000) | |
#define APB2PERIPH_BASE (PERIPH_BASE + 0x10000) | |
#define GPIOA_BASE (APB2PERIPH_BASE + 0x0800) | |
#define GPIOA (( GPIO_TypeDef *) GPIOA_BASE) |
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
uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx) { | |
return (( uint16_t)GPIOx ->IDR); | |
} |
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
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); |
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
#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; |
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
#include <stm32f10x_rcc.h> | |
#include <stm32f10x_gpio.h> | |
void Delay(uint32_t nTime); | |
int main(void) | |
{ | |
GPIO_InitTypeDef GPIO_InitStructure; | |
// Enable Peripheral Clocks | |
... (1) ... | |
// Configure Pins | |
... (2) ... |
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
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC , ENABLE); // (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
/* (2) */ | |
GPIO_StructInit (& GPIO_InitStructure); | |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; | |
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; | |
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; | |
GPIO_Init(GPIOC , &GPIO_InitStructure); |
OlderNewer