Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Saffet saffetblt

🎯
Focusing
View GitHub Profile
View GPTIM_Input_Capture_Freq_Period_Measurement.c
#include "stm32f4xx.h"
int period;
float freq;
int main(){
int last_value = 0;
int current_value = 0;
//Configure PA5 as alternate function mode
RCC->AHB1ENR |= 0x1; //Enable GPIOA
View GPTIM_Compare.c
#include "stm32f4xx.h" // Device header
/* Toggle PA5 at 1Hz using TIM2 Compare Mode */
int main(){
RCC->AHB1ENR |= 0x1; //Enable AHB1 clock bus
GPIOA->MODER |= (2<<10); //Set PA5 to Alternate Function Mode
GPIOA->AFR[0] |= (1<<20); //SET pin AF1 for TIM2_CH1
RCC->APB1ENR |= 0x1; //Enable TIM2 Clock Bus
TIM2->PSC = 1600; //16.000.000 dive by 1.600 = 10.000 (Prescaler Register)
View GPTIM_Basic.c
#include "stm32f4xx.h" // Device header
int main(){
//GPIO Config
RCC->AHB1ENR |=0x8;
GPIOD->MODER |= (1<<30);
//TIM2 Config @16Mhz
RCC->APB1ENR |= 0x1; //Enable TIM2 Clock Bus
TIM2->PSC = 1600-1; //16.000.000 dive by 1.600 = 10.000 (Prescaler Register)
View Stm32_Usart_Rx_Tx.c
#include "stm32f4xx.h" // Device header
#include "stdio.h"
void USART2_Init(void);
int main() {
int n;
char str[100];
USART2_Init();
View stdio_in_arm.c
struct __FILE{int handle;};
FILE __stdin = {0};
FILE __stdout = {1};
FILE __stderr = {2};
int fgetc(FILE *f){
int c;
c = USART2_Read();
if (c == '\r') {
USART2_Write(c);
View RCC_Init.c
void RCC_init(void){
/* Configure clocks
* Max SYSCLK: 168 MHz
* Max AHB: 168 Mhz
* Max APB1: 42 Mhz
* Max APB2: 84 Mhz
*/
// Flash settings: 5 CPU cycle wait, enable prefetch, instruction cache enable, data cache enable
FLASH->ACR = FLASH_ACR_LATENCY_5WS | FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN;
View ipvalid_test.go
package main
import "testing"
func TestPrivateIP(t *testing.T) {
isPrivate, _ := PrivateIP("192.168.1.6")
if !isPrivate {
t.Error(isPrivate)
}
}
View ipvalid.go
package main
import (
"errors"
"fmt"
"net"
"regexp"
"strings"
)
You can’t perform that action at this time.