Skip to content

Instantly share code, notes, and snippets.

View monpetit's full-sized avatar
💭
I may be slow to respond.

YoungSik Won monpetit

💭
I may be slow to respond.
View GitHub Profile
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define I2C_SLAVE_ADDRESS 0x4
#define MEASURE_TEMPERATURE 0xA0
#define SEND_TEMPERATURE 0xB0
const int reset_pin = 5;
uint32_t count = 10;
void software_reset(void)
{
digitalWrite(reset_pin, LOW);
}
void setup()
uint32_t count = 10;
void wdt_reset(void)
{
// Watchdog Timer initialization
// Watchdog Timer Prescaler: OSC/2k (2048 cycles)
// Watchdog timeout action: Reset
WDTCSR = (0 << WDIF) | (0 << WDIE) | (0 << WDP3) | (1 << WDCE) | (1 << WDE) | (0 << WDP2) | (0 << WDP1) | (0 << WDP0);
#include "inc/hw_types.h"
#include "driverlib/prcm.h"
#include "driverlib/wdt.h"
void wdt_reset(void)
{
// Watchdog 활성화, clock source 지정
MAP_PRCMPeripheralClkEnable(PRCM_WDT, PRCM_RUN_MODE_CLK);
// WDT 레지스터 잠금 해제
#include "inc/hw_types.h"
#include "driverlib/prcm.h"
#define SLOW_CLK_FREQ (32*1024)
void hibernate_reset(void)
{
// 동면에서 깨어날 시간(RTC) 설정 (본 예제는 1초)
MAP_PRCMHibernateIntervalSet(1 * SLOW_CLK_FREQ);
@monpetit
monpetit / stm32_hal_uart_receive_it_example.c
Created May 7, 2016 13:06
STM32 HAL Driver Receive with Interrupt example
#include "stm32f1xx_hal.h"
UART_HandleTypeDef UartHandle; /* UART 핸들러 */
__IO ITStatus UartReady = RESET; /* UART 상태 지시자 */
#define RXBUFFERSIZE 10
uint8_t aRxBuffer[RXBUFFERSIZE]; /* UART 수신 버퍼 */
int main(void)
@monpetit
monpetit / arduino_serial_process_in_loop.ino
Last active May 8, 2016 07:13
아두이노 시리얼 데이터 수신 모듈의 구조
void loop()
{
char ch;
while (Serial.available()) {
ch = Serial.read();
/* 수신된 데이터 처리 */
/* ... */
}
/* UART 데이터가 없을 때 */
#include "stm32f1xx_hal.h"
#include "ringbuf.h"
UART_HandleTypeDef huart2;
#define RBSIZE 256
ringbuffer_t rb; // 링버퍼 변수
uint8_t rbrawbuffer[RBSIZE]; // 링버퍼의 raw 버퍼
uint8_t userbuffer[RBSIZE]; // 링버러에서 데이터를 꺼낼 사용자 버퍼
@monpetit
monpetit / empty_project.c
Created May 11, 2016 02:49
efm32 empty project source
/**************************************************************************//**
* @file
* @brief Empty Project
* @author Energy Micro AS
* @version 3.20.2
******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
//=========================================================
// src/InitDevice.c: generated by Hardware Configurator
//
// This file will be regenerated when saving a document.
// leave the sections inside the "$[...]" comment tags alone
// or they will be overwritten!
//=========================================================
// USER INCLUDES
#include "InitDevice.h"