--- /dev/null
+arduino MCU port tiny45 tiny2313
+GND GND 4 10
+5V VCC 8 20
+10 RESET 1 1
+11 MOSI/SDA 5 17
+12 MISO/DO 6 18
+13 SCK/USCK/SCL 7 19
+
+avrdude -cstk500v1 -P/dev/ttyUSB0 -b19200 -p attiny2313
--- /dev/null
+#MCU=at90s2313
+MCU=attiny2313
+CC=avr-gcc
+OBJCOPY=avr-objcopy
+PROJECT=helloworld
+# optimize for size:
+CFLAGS=-g -mmcu=$(MCU) -Wall -Wstrict-prototypes -Os -mcall-prologues
+#-------------------
+all: $(PROJECT).hex
+#-------------------
+$(PROJECT).hex : $(PROJECT).out
+ $(OBJCOPY) -R .eeprom -O ihex $(PROJECT).out $(PROJECT).hex
+$(PROJECT).out : $(PROJECT).o
+ $(CC) $(CFLAGS) -o $(PROJECT).out -Wl,-Map,$(PROJECT).map $(PROJECT).o
+$(PROJECT).o : $(PROJECT).c
+ $(CC) $(CFLAGS) -Os -c $(PROJECT).c
+asm : $(PROJECT).c
+ $(CC) $(CFLAGS) -O -S $(PROJECT).c
+# you need to erase first before loading the program.
+# load (program) the software into the eeprom:
+load: $(PROJECT).hex
+ avrdude -cstk500v1 -P/dev/ttyUSB0 -b19200 -p $(MCU) -Uflash:w:$(PROJECT).hex:i
+ # uisp -dlpt=/dev/parport0 --erase --upload --verify if=$(PROJECT).hex -dprog=dapa -v=3 --hash=12
+#-------------------
+clean:
+ rm -f *.o *.map *.out *.hex
+#-------------------
--- /dev/null
+#define F_CPU 100000UL // Sets up the default speed for delay.h
+// this is the header file that tells the compiler what pins and ports, etc.
+// are available on this chip.
+#include <avr/io.h>
+
+// define what pins the LEDs are connected to.
+// in reality, PD6 is really just '6'
+#define LED PD5
+
+// Some macros that make the code more readable
+#define output_low(port,pin) port &= ~(1<<pin)
+#define output_high(port,pin) port |= (1<<pin)
+#define set_input(portdir,pin) portdir &= ~(1<<pin)
+#define set_output(portdir,pin) portdir |= (1<<pin)
+
+// this is just a program that 'kills time' in a calibrated method
+void delay_ms(uint8_t ms) {
+ uint16_t delay_count = F_CPU / 17500;
+ volatile uint16_t i;
+
+ while (ms != 0) {
+ for (i=0; i != delay_count; i++);
+ ms--;
+ }
+}
+
+int main(void) {
+ // initialize the direction of PORTD #6 to be an output
+ set_output(DDRD, LED);
+
+ while (1) {
+ // turn on the LED for 200ms
+ output_high(PORTD, LED);
+ delay_ms(200);
+ // now turn off the LED for another 200ms
+ output_low(PORTD, LED);
+ delay_ms(200);
+ // now start over
+ }
+}
--- /dev/null
+#include <avr/io.h>
+#include <util/delay.h>
+
+//#include <compat/deprecated.h>
+/*
+variable = PINx; // Read a byte from a port, replace x with the port number
+PORTx = variable; //Write a byte to a port
+PORTx |= 1<<pin_number; // Set a pin in a port
+PORTx &= ~(1<<pin_number); // Clear a pin in a port
+*/
+
+void delay(unsigned int ms) {
+ unsigned int i,j;
+ for ( j=0; j<1000; j++)
+ for ( i=0; i<ms; i++);
+}
+
+int main (void){
+
+ //sbi(DDRD,PD5); /*enable port 5 for output*/
+ DDRD |= 1<<5;
+
+ while (1) {
+ //cbi (PORTD, PD5);
+ PORTD &= ~(1<<5);
+ delay (500);
+ //sbi (PORTD, PD5);
+ PORTD |= 1<<5;
+ delay (500);
+ }
+
+ return 0;
+}
* usage ./strobe [frequency]
*/
+//#define __WIN32__
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
+#ifndef __WIN32__
+ #include <fcntl.h>
+#else
+ #include <windows.h>
+#endif
void signal_handler(int signo) {
if(signo == SIGTERM || signo == SIGINT || signo == SIGQUIT) {
fputs(state_a, stdout);
fflush(stdout);
usleep(half_interval);
+ #ifndef __WIN32__
+ int fflags = fcntl(fileno(stdin), F_GETFL, 0);
+ fcntl(fileno(stdin), F_SETFL, fflags | O_NONBLOCK);
+ while(getchar()) puts(".");
+ fcntl(fileno(stdin), F_SETFL, fflags);
+ #else
+ //WARNING! Somehow implement FILE_FLAG_OVERLAPPED & FILE_FLAG_NO_BUFFERING support on windows
+ #endif
if(argc > 2) getchar(); //interactive strobe
fputs(state_b, stdout);
fflush(stdout);