Skip to content

Instantly share code, notes, and snippets.

@goog
goog / token.c
Created December 29, 2021 10:37
char *strtok(char *str, const char *delimiters)
{
char *token = NULL;
static char *begin = NULL;
if(str != NULL)
{
begin = str;
}
else
{
/**
******************************************************************************
* @file Project/main.c
* @author MCD Application Team
* @version V2.3.0
* @date 16-June-2017
* @brief Main program body
******************************************************************************
* @attention
*
/**
* @file
*
* @ingroup arm
*
* @brief RTC driver for STM32F4 SoC.
*
*/
/*
void rtc_init(int minor)
{
printk("rtc \n");
volatile uint32_t *RCC_APB1ENR = 0x40023840;
volatile uint32_t *RCC_BDCR = 0x40023870;
uint16_t retry = 0X1FFF;
uint32_t *USART2_SR = (uint32_t *)0x40004400;
uint32_t *USART2_DR = (uint32_t *)0x40004404;
rtems_isr USART2_handler(rtems_vector_number vector)
{
uint32_t temp = temp;
if((*USART2_SR) & (1<<5))
{
@goog
goog / test.c
Created April 11, 2019 11:39
rtems stm32f4
stm32f4_gpio_config io_key2 =
{
.fields={
.pin_first = STM32F4_GPIO_PIN(4, 2),
.pin_last = STM32F4_GPIO_PIN(4, 2),
.mode = STM32F4_GPIO_MODE_INPUT,
//.otype = STM32F4_GPIO_OTYPE_PUSH_PULL,
.ospeed = STM32F4_GPIO_OSPEED_2_MHZ,
.pupd = STM32F4_GPIO_PULL_UP,
.output = 0,
```
cheng@ubuntu:~/rtems-4.11.3/testsuites/samples/hello$ tree
.
├── hello.doc
├── hello.scn
├── init__0402.c
├── init0403.c
├── init.c
├── init.c_0001
├── init.c_0002
#include "keymap_common.h"
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: numpad */
KEYMAP( NLCK, SLASH, PAST, PMNS, \
P7, P8, P9, PENT, \
P4, P5, P6, \
P1, P2, P3, \
P0, PDOT, PPLS),
@goog
goog / rc.local
Created April 10, 2016 09:34
brightness setting backup
cheng@ada ~ $ cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
@goog
goog / iconv_practice.cpp
Last active September 11, 2015 10:24 — forked from suapapa/iconv_practice.cpp
iconv utf8 to ucs2 example
#include <stdio.h>
#include <iconv.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>
int conv_utf8_to_ucs2(const char* src, size_t len)
{
iconv_t cb = iconv_open("UTF-16", "UTF-8");
if (cb == (iconv_t)(-1))