aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sw/Makefile24
-rw-r--r--sw/main.c44
2 files changed, 68 insertions, 0 deletions
diff --git a/sw/Makefile b/sw/Makefile
new file mode 100644
index 0000000..36538cb
--- /dev/null
+++ b/sw/Makefile
@@ -0,0 +1,24 @@
+CC = xc8-cc
+INCLUDES = -I./ -I/home/sam/prog/mla/v2018_11_26/framework/usb/inc
+CFLAGS = -mcpu=pic16f1459 -std=c99 $(INCLUDES) -Wall
+LDFLAGS =
+
+OUT = can_gauge
+SRC = $(wildcard *.c)
+HDR = $(wildcard *.h)
+
+HEX = $(OUT).hex
+OBJ = $(SRC:.c=.p1)
+
+$(HEX): $(OBJ)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
+
+%.p1: %.c
+ $(CC) $(CFLAGS) -c $<
+
+clean:
+ rm -f $(OBJ) $(HEX) *.d *.p1 *.lst *.rlf *.o *.s *.sdb *.sym *.hxl *.elf *.cmf
+
+$(OBJ): $(HDR)
+
+.PHONY: clean
diff --git a/sw/main.c b/sw/main.c
new file mode 100644
index 0000000..c79b6e8
--- /dev/null
+++ b/sw/main.c
@@ -0,0 +1,44 @@
+#include <xc.h>
+
+// CONFIG1
+#pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator: I/O function on CLKIN pin)
+#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
+#pragma config PWRTE = OFF // Power-up Timer Enable (PWRT disabled)
+#pragma config MCLRE = ON // MCLR Pin Function Select (MCLR pin is MCLR)
+#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
+#pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
+#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
+#pragma config IESO = OFF // Internal/External Switchover Mode (Internal/External Switchover Mode is disabled)
+#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is disabled)
+
+// CONFIG2
+#pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
+#pragma config CPUDIV = NOCLKDIV// CPU System Clock Selection Bit (NO CPU system divide)
+#pragma config USBLSCLK = 48MHz // USB Low SPeed Clock Selection bit (System clock expects 48 MHz, FS/LS USB CLKENs divide-by is set to 8.)
+#pragma config PLLMULT = 3x // PLL Multipler Selection Bit (3x Output Frequency Selected)
+#pragma config PLLEN = ENABLED // PLL Enable Bit (3x or 4x PLL Enabled)
+#pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
+#pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
+#pragma config LPBOR = OFF // Low-Power Brown Out Reset (Low-Power BOR is disabled)
+#pragma config LVP = ON // Low-Voltage Programming Enable
+
+static void
+clock_init(void) {
+ OSCCON = 0xFC; // HFINTOSC @ 16MHz, 3x PLL, PLL enabled
+ ACTCON = 0x90; // active clock tuning enabled for USB
+}
+
+static void
+gpio_init(void) {
+
+}
+
+void
+main(void) {
+ clock_init();
+ gpio_init();
+
+ for (;;) {
+
+ }
+}