Parameterize processor settings

i2c
Savanni D'Gerinel 2022-07-12 23:09:04 -04:00
parent 6787d7484e
commit 6c02253868
1 changed files with 27 additions and 15 deletions

View File

@ -9,6 +9,11 @@
let
version = builtins.string 0 8 self.lastModifiedDate;
supportedSystems = [ "x86_64-linux" "avr-none" ];
cflags = { mcu, chip_select, f_cpu }: ''-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}'';
attiny85 = { mcu = "attiny85"; chip_select = "AVR_ATtiny85"; f_cpu = "8000000"; };
atmega32u4 = { mcu = "atmega32u4"; chip_select = "AVR_ATmega32u4"; f_cpu = "8000000"; };
processor = atmega32u4;
in rec
{
defaultPackage."x86_64-linux" =
@ -17,13 +22,27 @@
in pkgs.symlinkJoin {
name = "avr-monorepo";
paths = [
packages."x86_64-linux"."flame"
packages."x86_64-linux"."prime-tx"
packages."x86_64-linux"."radio-rx"
(packages."x86_64-linux"."flame" processor)
(packages."x86_64-linux"."prime-tx" processor)
(packages."x86_64-linux"."radio-rx" processor)
];
};
/*
packages."x86_64-linux"."base" =
{ mcu, chip_select, f_cpu }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
avr = pkgs.pkgsCross.avr.buildPackages;
in pkgs.stdenv.mkDerivation rec {
name = "base";
src = ./.;
};
*/
packages."x86_64-linux"."flame" =
{ mcu, chip_select, f_cpu }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
avr = pkgs.pkgsCross.avr.buildPackages;
@ -31,10 +50,7 @@
name = "flame";
src = ./.;
MCU = "attiny85";
CHIP_SELECT = "AVR_ATtiny85";
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}'';
CFLAGS = cflags { inherit mcu chip_select f_cpu; };
buildPhase = ''
${avr.gcc}/bin/avr-gcc ${CFLAGS} -I${src}/base -o base.o -c ${src}/base/base.c
@ -50,6 +66,7 @@
};
packages."x86_64-linux"."prime-tx" =
{ mcu, chip_select, f_cpu }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
lib = pkgs.lib;
@ -60,10 +77,7 @@
includes = [ "base" "spi" "shift_register" "rfm69hcw" "display" ];
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'';
CFLAGS = cflags { inherit mcu chip_select f_cpu; };
INCLUDE_DIRS = lib.concatStringsSep " " (map (dir: "-I${src}/${dir}") includes);
buildPhase = ''
@ -82,6 +96,7 @@
};
packages."x86_64-linux"."radio-rx" =
{ mcu, chip_select, f_cpu }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
lib = pkgs.lib;
@ -92,10 +107,7 @@
includes = [ "base" "spi" "shift_register" "rfm69hcw" "display" ];
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'';
CFLAGS = cflags { inherit mcu chip_select f_cpu; };
INCLUDE_DIRS = lib.concatStringsSep " " (map (dir: "-I${src}/${dir}") includes);
buildPhase = ''