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
@monpetit
monpetit / efm32_systick_util.c
Created May 12, 2016 05:54
efm32 systick setup
#include "em_device.h"
#include "em_cmu.h"
#include "systick_util.h"
volatile uint32_t systick_count = 0;
void setup_systick_timer(void)
{
@monpetit
monpetit / efm32g210f128_main_00.c
Created May 12, 2016 06:14
main function of example project
#include "em_device.h"
#include "em_chip.h"
#include "em_gpio.h"
#include "InitDevice.h"
#include "systick_util.h"
/**************************************************************************//**
* @brief Main function
*****************************************************************************/
int main(void)
@monpetit
monpetit / efm32g210f128_initdevice_01_lm35_adc0.c
Created May 25, 2016 05:51
lm35 temperature sensor adc0
//=========================================================
// 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"
/**************************************************************************//**
* @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>
*******************************************************************************
*
void ssd1306_command(uint8_t c)
{
if (use_i2c) {
static uint8_t control = 0x00;
I2C_TransferSeq_TypeDef seq;
seq.addr = (0x3C << 1);
seq.flags = I2C_FLAG_WRITE_WRITE;
seq.buf[0].data = &control;
seq.buf[0].len = 1;
void ssd1306_data(uint8_t c)
{
if (use_i2c) {
static uint8_t control = 0x40;
I2C_TransferSeq_TypeDef seq;
seq.addr = (0x3C << 1);
seq.flags = I2C_FLAG_WRITE_WRITE;
seq.buf[0].data = &control;
seq.buf[0].len = 1;
#include <stdlib.h>
#include <stdint.h>
typedef uint8_t u08;
#define RAND8() (rand() % 256)
#define RGB_LED_PORT (gpioPortE)
#define RGB_LED_PIN (11)
#define LED_HI() GPIO_PinOutSet(RGB_LED_PORT, RGB_LED_PIN)
#define LED_LO() GPIO_PinOutClear(RGB_LED_PORT, RGB_LED_PIN)
void reset_blink_rgb(void)
{
volatile u08 countdown = 30;
while (countdown--) {
show_rgb(0, 255, 0);
show_rgb(255, 0, 0);
__delay_ms(15);
show_rgb(0, 0, 0);
show_rgb(0, 0, 0);
const int measurePin = A0;
const int ledPower = 3;
const int samplingTime = 280;
const int deltaTime = 40;
const int sleepTime = 9680;
float voMeasured = 0;
void adc10_measure_dust_density(void)
{
digitalWrite(ledPower, LOW); // LED 켜기
void setup_timer1(void)
{
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 62.500 kHz
// Mode: CTC top=OCR1A
// OC1A output: Disconnected
// OC1B output: Disconnected
// Noise Canceler: Off
// Input Capture on Falling Edge