Skip to content

Instantly share code, notes, and snippets.

View TNKSoftware's full-sized avatar

Tanaka Yusuke TNKSoftware

View GitHub Profile
@TNKSoftware
TNKSoftware / xbox.ino
Created February 26, 2021 12:07
Arduino code to communicate with xbox 360 RF module
/*
Arduino code to communicate with xbox 360 RF module.
https://www.electromaker.io/project/view/xbox-360-rf-module-controlled-with-an-arduino-1
GNU General Public License, version 3 or later (GPL3+)
*/
#include <avr/sleep.h>
#define sync_pin 2 // 電源ボタンをペアリングボタン代わりにする
#define data_pin 3 // データ線
@TNKSoftware
TNKSoftware / pa_in_main.c
Created June 17, 2019 08:06
PSoC Parallel input exsample in C
#include "project.h"
CY_ISR(OnIntrupptPaIn)
{
uint8_t v = pa_in_GetValue();
for(int i = 0; i < 8; i++){
UART_PutChar((v & 0x80) ? '1' : '0');
v <<= 1;
}
}
@TNKSoftware
TNKSoftware / pa_in_api.h
Created June 17, 2019 07:10
PSoC getting A0 register value API example
#ifndef __`$INSTANCE_NAME`_H__
#define __`$INSTANCE_NAME`_H__
#define `$INSTANCE_NAME`_GetValue() CY_GET_REG8(`$INSTANCE_NAME`_dp__A0_REG)
#endif
@TNKSoftware
TNKSoftware / pa_in.v
Created June 17, 2019 07:02
PSoC parallel input exsample
`include "cypress.v"
module pa_in (
input clock,
output isr
);
localparam RG_IDLE = 3'b000;
localparam RG_COPY = 3'b001;
reg [2:0]rg_state;
@TNKSoftware
TNKSoftware / paltosingle.v
Last active June 16, 2019 02:46
Parallel to single wire
module pa_out (
input clock,
output led1,
output led2,
output led3
);
reg [7:0] led_out;
assign led1 = led_out[2];
@TNKSoftware
TNKSoftware / nanaseg_main.c
Created June 15, 2019 06:56
PSoC 7-segment LED software sample
#include "project.h"
// LED number -> Pin's position
#define SEG_LA 0b00000001
#define SEG_LB 0b00000010
#define SEG_LC 0b00000100
#define SEG_LP 0b00001000
#define SEG_LD 0b00010000
#define SEG_LE 0b00100000
#define SEG_LF 0b10000000
@TNKSoftware
TNKSoftware / pa_out_api.h
Last active June 16, 2019 02:47
PSoC API Header file sample
#ifndef __`$INSTANCE_NAME`_H__
#define __`$INSTANCE_NAME`_H__
#ifndef __PA_OUT_DEFINED__
#define __PA_OUT_DEFINED__
#define SEG_0 (SEG_LA | SEG_LB | SEG_LC | SEG_LD | SEG_LE | SEG_LF)
#define SEG_1 (SEG_LB | SEG_LC)
#define SEG_2 (SEG_LA | SEG_LB | SEG_LD | SEG_LE | SEG_LG)
#define SEG_3 (SEG_LA | SEG_LB | SEG_LC | SEG_LD | SEG_LG)
@TNKSoftware
TNKSoftware / nanaseg.v
Created June 15, 2019 05:27
Verilog 7-Seg driver demo for PSoC
`include "cypress.v"
module pa_out (
input clock,
output[7:0] led_out
);
cy_psoc3_dp #(.cy_dpconfig(
{
`CS_ALU_OP_PASS, `CS_SRCA_A0, `CS_SRCB_D0,
@TNKSoftware
TNKSoftware / flipflop.v
Created June 11, 2019 08:56
Flip-Flop logic for Verilog
`include "cypress.v"
module flipflop (
input button_in,
output led_out
);
reg ff;
always @(posedge button_in)
@TNKSoftware
TNKSoftware / psoc4_hello.c
Last active June 11, 2019 05:40
Hello world program for PSoC 4
#include "project.h"
int main(void)
{
CyGlobalIntEnable;
CyDelay(1000); // wait 1000ms
UART_1_Start();
UART_1_UartPutString("Hello World!\n");