Remove dead diagnostic apps

i2c
Savanni D'Gerinel 2022-07-12 22:41:50 -04:00
parent 7846fa175f
commit f76bcb18a2
6 changed files with 0 additions and 462 deletions

View File

@ -101,99 +101,6 @@
'';
};
packages."x86_64-linux"."spi_test" =
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
lib = pkgs.lib;
avr = pkgs.pkgsCross.avr.buildPackages;
in pkgs.stdenv.mkDerivation rec {
name = "spi-test";
src = ./.;
includes = [ "base" "spi" ];
MCU = "atmega32u4";
CHIP_SELECT = "AVR_ATmega32u4";
F_CPU = "8000000";
CFLAGS = ''-O -finline-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Werror -Wstrict-prototypes -DF_CPU=${F_CPU} -std=gnu99 -D__${CHIP_SELECT}__=1 -mmcu=${MCU} -DAVR=1'';
INCLUDE_DIRS = lib.concatStringsSep " " (map (dir: "-I${src}/${dir}") includes);
buildPhase = ''
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o spi.o -c ${src}/spi/spi.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o main.o -c ${src}/spi_test/main.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} -o main.elf main.o spi.o
$OBJCOPY -O ihex main.elf main.hex
'';
installPhase = ''
mkdir $out
cp main.elf main.hex $out
'';
};
packages."x86_64-linux"."lcd" =
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
lib = pkgs.lib;
avr = pkgs.pkgsCross.avr.buildPackages;
in pkgs.stdenv.mkDerivation rec {
name = "lcd";
src = ./.;
includes = [ "base" "display" "shift_register" "spi" ];
MCU = "atmega32u4";
CHIP_SELECT = "AVR_ATmega32u4";
F_CPU = "8000000";
CFLAGS = ''-O -finline-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Werror -Wstrict-prototypes -DF_CPU=${F_CPU} -std=gnu99 -D__${CHIP_SELECT}__=1 -mmcu=${MCU} -DAVR=1'';
INCLUDE_DIRS = lib.concatStringsSep " " (map (dir: "-I${src}/${dir}") includes);
buildPhase = ''
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o base.o -c ${src}/base/base.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o spi.o -c ${src}/spi/spi.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o reg.o -c ${src}/shift_register/shift_register.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o display.o -c ${src}/display/display.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o main.o -c ${src}/lcd/main.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} -o main.elf main.o display.o reg.o spi.o base.o
$OBJCOPY -O ihex main.elf main.hex
'';
installPhase = ''
mkdir $out
cp main.elf main.hex $out
'';
};
packages."x86_64-linux"."rfm_diagnostic" =
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
lib = pkgs.lib;
avr = pkgs.pkgsCross.avr.buildPackages;
in pkgs.stdenv.mkDerivation rec {
name = "lcd";
src = ./.;
includes = [ "base" "display" "shift_register" "spi" "rfm69hcw" ];
MCU = "atmega32u4";
CHIP_SELECT = "AVR_ATmega32u4";
F_CPU = "8000000";
CFLAGS = ''-O -finline-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Werror -Wstrict-prototypes -DF_CPU=${F_CPU} -std=gnu99 -D__${CHIP_SELECT}__=1 -mmcu=${MCU} -DAVR=1'';
INCLUDE_DIRS = lib.concatStringsSep " " (map (dir: "-I${src}/${dir}") includes);
buildPhase = ''
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o base.o -c ${src}/base/base.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o spi.o -c ${src}/spi/spi.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o reg.o -c ${src}/shift_register/shift_register.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o display.o -c ${src}/display/display.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o rfm.o -c ${src}/rfm69hcw/rfm.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o main.o -c ${src}/rfm_diagnostic/main.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} -o main.elf main.o display.o rfm.o reg.o spi.o base.o
$OBJCOPY -O ihex main.elf main.hex
'';
installPhase = ''
mkdir $out
cp main.elf main.hex $out
'';
};
devShell."x86_64-linux" =
let
pkgs = import nixpkgs { system = "x86_64-linux"; };

View File

@ -1,49 +0,0 @@
/*
Copyright 2022, Savanni D'Gerinel <savanni@luminescent-dreams.com>
This file is part of Savanni's AVR library.
Lumeto is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Lumeto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
*/
#include <avr/io.h>
#include <util/delay.h>
#include <base.h>
#include <spi.h>
#include <shift_register.h>
#include <display.h>
int main(void) {
display_t display = {
.reg = {
.output = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 5 },
.latch_clock = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 6 },
.shift_clock = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 7 },
},
.register_select = { .ddr = &DDRF, .port = &PORTF, .pin = &PINF, .addr = 1 },
.enable = { .ddr = &DDRF, .port = &PORTF, .pin = &PINF, .addr = 0 },
};
gpio_t light = { .ddr = &DDRC, .port = &PORTC, .pin = &PINC, .addr = 7 };
set_line_direction(&light, LINE_OUT);
clear_line(&light);
display_init(&display);
display_clear(&display);
_delay_ms(500);
display_write_message(&display, "Hello, my bat");
display_set_location(&display, 0, 1);
display_write_message(&display, " -- Savanni");
display_enable(&display);
set_line(&light);
while(1) { _delay_ms(1); }
}

View File

@ -1,37 +0,0 @@
/*
Copyright 2022, Savanni D'Gerinel <savanni@luminescent-dreams.com>
This file is part of Savanni's AVR library.
Lumeto is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Lumeto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
*/
#include <avr/io.h>
#include <util/delay.h>
#include <base.h>
int main (void) {
DDRB = 0x18;
PORTB = 0x00;
_delay_ms(500);
io_pin_t enable_pin = { .port = &PORTB, .pin = 3 };
io_pin_t data_pin = { .port = &PORTB, .pin = 4 };
set_pin(&enable_pin);
for (uint8_t i = 0; i < 10; i++) {
set_pin(&data_pin);
_delay_ms(500);
clear_pin(&data_pin);
_delay_ms(500);
}
clear_pin(&enable_pin);
while(1) {};
}

View File

@ -1,219 +0,0 @@
/*
Copyright 2022, Savanni D'Gerinel <savanni@luminescent-dreams.com>
This file is part of Savanni's AVR library.
Lumeto is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Lumeto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
*/
#include <avr/io.h>
#include <util/delay.h>
#include <base.h>
#include <spi.h>
#include <rfm.h>
#include <display.h>
#include <stdio.h>
void display_current_mode(display_t *display, rfm_t *rfm) {
display_clear(display);
uint8_t mode = rfm_mode(rfm);
char msg[40];
sprintf(msg, "Mode: 0x%02x", mode);
display_write_message(display, msg);
display_set_location(display, 1, 0);
display_write_message(display, ": ");
if (mode & _BV(7)) {
display_write_message(display, "SO ");
}
if (mode & _BV(6)) {
display_write_message(display, "LO ");
}
if (mode & _BV(5)) {
display_write_message(display, "LA ");
}
uint8_t tr_op_mode = (mode & 0b00011100) >> 2;
switch (tr_op_mode) {
case 0: display_write_message(display, "Sleep");
break;
case 1: display_write_message(display, "Standby");
break;
case 2: display_write_message(display, "FS");
break;
case 3: display_write_message(display, "TX");
break;
case 4: display_write_message(display, "RS");
}
}
void display_temperature(display_t *display, rfm_t *rfm) {
display_clear(display);
uint8_t temperature = rfm_temperature(rfm);
display_write_message(display, "Temperature:");
display_set_location(display, 1, 0);
char temp_str[8];
sprintf(temp_str, ": %d", temperature);
display_write_message(display, temp_str);
}
void display_status_flags(display_t *display, rfm_t *rfm) {
display_clear(display);
display_write_message(display, "Status:");
display_set_location(display, 1, 0);
display_write_message(display, ": ");
uint8_t status = rfm_status(rfm);
if (status & _BV(7)) {
display_write_message(display, "FF ");
}
if (status & _BV(6)) {
display_write_message(display, "FNE ");
}
if (status & _BV(5)) {
display_write_message(display, "FL ");
}
if (status & _BV(4)) {
display_write_message(display, "FO ");
}
if (status & _BV(3)) {
display_write_message(display, "PS ");
}
if (status & _BV(2)) {
display_write_message(display, "PR ");
}
if (status & _BV(1)) {
display_write_message(display, "Ok ");
}
}
void display_irq_flags(display_t *display, rfm_t *rfm) {
display_clear(display);
display_write_message(display, "IRQ:");
display_set_location(display, 1, 0);
display_write_message(display, ": ");
uint8_t flags = rfm_irq_1(rfm);
if (flags & _BV(7)) {
display_write_message(display, "MR ");
}
if (flags & _BV(6)) {
display_write_message(display, "RR ");
}
if (flags & _BV(5)) {
display_write_message(display, "TR ");
}
if (flags & _BV(4)) {
display_write_message(display, "PL ");
}
if (flags & _BV(3)) {
display_write_message(display, "RS ");
}
if (flags & _BV(2)) {
display_write_message(display, "TO ");
}
if (flags & _BV(1)) {
display_write_message(display, "AO ");
}
if (flags & _BV(0)) {
display_write_message(display, "SM ");
}
}
void display_frequency(display_t *display, rfm_t *rfm) {
display_clear(display);
display_write_message(display, "Frequency: ");
display_set_location(display, 1, 0);
uint32_t frequency = rfm_frequency(rfm);
char temp_str[32];
sprintf(temp_str, ": %lu", frequency);
display_write_message(display, temp_str);
}
void display_bits(display_t *display, uint8_t bits) {
display_clear(display);
char value[8];
sprintf(value, "0x%02x", bits);
display_write_message(display, value);
display_set_location(display, 1, 0);
for (int i = 7; i >= 0; i--) {
if (bits & _BV(i)) {
display_write_message(display, "1");
} else {
display_write_message(display, "0");
}
}
}
void strobe_light(gpio_t *light) {
set_line(light);
_delay_ms(100);
clear_line(light);
_delay_ms(100);
}
int main(void) {
display_t display = {
.reg = {
.output = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 7 },
.shift_clock = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 6 },
.latch_clock = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 5 },
},
};
gpio_t light = { .ddr = &DDRC, .port = &PORTC, .pin = &PINC, .addr = 7 };
set_line_direction(&light, LINE_OUT);
strobe_light(&light);
strobe_light(&light);
strobe_light(&light);
_delay_ms(15);
display_init(&display);
rfm_t rfm = {
.spi = {
.clock = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 1 },
.data_out = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 2 },
.data_in = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 3 },
.chip_select = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 4 },
},
.irq = { .ddr = &DDRE, .port = &PORTE, .pin = &PINE, .addr = 6 },
.reset = { .ddr = &DDRD, .port = &PORTD, .pin = &PIND, .addr = 4 },
};
rfm_initialize(&rfm);
display_enable(&display);
display_clear(&display);
display_write_message(&display, "Waking up");
_delay_ms(1000);
rfm_set_mode(&rfm, standby);
rfm_listen(&rfm);
while(1) {
display_status_flags(&display, &rfm);
_delay_ms(5000);
display_current_mode(&display, &rfm);
_delay_ms(5000);
display_irq_flags(&display, &rfm);
_delay_ms(5000);
display_frequency(&display, &rfm);
_delay_ms(5000);
}
}

View File

@ -1,28 +0,0 @@
MCU=attiny85
CHIP_SELECT=AVR_ATtiny85
F_CPU=8000000
CFLAGS=-O -finline-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -DF_CPU=${F_CPU} -std=gnu99 -D__${CHIP_SELECT}__=1
LINKFLAGS=-mmcu=${MCU}
OBJECTS= main.o \
sk9822.o
.SUFFIXES: .c .o .h
# /nix/store/fymsi5yk07jvcbdaka6nfhx6s2a7kgpi-avr-stage-final-gcc-debug-wrapper-10.3.0/bin/avr-gcc -O -finline-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -DF_CPU=8000000 -std=gnu99 -D__AVR_ATtiny85__=1 -mmcu=attiny85 -I../base/include/ -E -o main.E src/main.c
main: main.o sk9822.o
# ${GCC}/bin/avr-gcc ${CFLAGS} -I../base/include/ -E -o main.E src/main.c
# ${GCC}/bin/avr-gcc ${CFLAGS} -I../base/include/ -S -o main.S src/main.c
echo ${GCC}
${GCC}/bin/avr-gcc ${CFLAGS} ${LINKFLAGS} -I../base/include/ -o main.elf main.o sk9822.o
${OBJCOPY} -O ihex main.elf main.hex
%.o: %.c %.h
${GCC}/bin/avr-gcc ${CFLAGS} -I../base/include/ -o $@ -c $<
clean:
rm *.o make.elf main.hex main.S main.E

View File

@ -1,36 +0,0 @@
#include <avr/io.h>
#include <util/delay.h>
#include <base.h>
#include <spi.h>
int main(void) {
spi_t spi = (spi_t){
.clock = { .ddr = &DDRF, .port = &PORTF, .addr = 7 },
.data_out = { .ddr = &DDRF, .port = &PORTF, .addr = 6 },
.data_in = { .ddr = &DDRF, .port = &PORTF, .addr = 5 },
.chip_select = { .ddr = &DDRF, .port = &PORTF, .addr = 4 },
};
io_pin_t light = { .ddr = &DDRC, .port = &PORTC, .addr = 7 };
initialize_spi(&spi);
while (1) {
set_pin(&light);
transfer_byte(&spi, 0xaa);
_delay_ms(1000);
clear_pin(&light);
_delay_ms(1000);
}
/*
while(1) {
set_pin(&spi.clock);
set_pin(&spi.data_out);
_delay_ms(500);
clear_pin(&spi.clock);
clear_pin(&spi.data_out);
_delay_ms(500);
}
*/
}