Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AXIOM_Remote_Firmware_Visualizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ FILE(GLOB GL3W_SOURCES "${CMAKE_SOURCE_DIR}/3rdParty/gl3w/GL/gl3w.c")
FILE(GLOB FIRMWARE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/UI/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/UI/Painter/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/UI/Screens/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/UI/Widgets/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/CentralDB/Attribute.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/CentralDB/CentralDB.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/CentralDB/CentralDBObserver.cpp"
Expand Down
44 changes: 38 additions & 6 deletions Firmware/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include <xc.h>
#include <sys/attribs.h>

// Configuration
#include "Configuration/PIC32.h"

Expand Down Expand Up @@ -28,7 +31,7 @@
// Defined in procdefs.ld
volatile extern uint16_t framebuffer[ILI9341_TFTWIDTH * ILI9341_TFTHEIGHT];
ILI9341Display display(framebuffer);

uint8_t fps = 0, frames = 0;
void ConfigGPIO()
{
// Enable pull-up resistor for E9 to prevent UANT RX interferences
Expand All @@ -44,6 +47,9 @@ void InitPBUS(void)
PB7DIVbits.PBDIV = 0b000000; // divide by 1
PB7DIVbits.ON = 1;

PB3DIVbits.PBDIV = 13; // divide by 12, 192Mhz/12 = 16Mhz
PB3DIVbits.ON = 1;

CFGCONbits.OCACLK = 1;
TRISDbits.TRISD10 = 0;
RPD10R = 0b1100;
Expand Down Expand Up @@ -532,8 +538,35 @@ void init_uart2()
irq_enable();
}

int main()
//ISR
extern "C" void __ISR(_TIMER_2_VECTOR, IPL7SOFT) Timer2_ISR(void)
{
fps = frames;
frames = 0;
IFS0bits.T2IF = 0; //clear flag

}

void InitTimer2(){

T2CONbits.TCS = 0; //Internal Clock
T2CONbits.TCKPS = 0b111; //1:256 Prescale value
TMR2 = 0; //Value of timer 2
PR2 = 62500; // (62500/16Mhz)x256 = 1
T2CONbits.ON = 1;

//Timer 2 Interrupt
IPC2bits.T2IP = 7;
IPC2bits.T2IS = 0;
IFS0bits.T2IF = 0;
IEC0bits.T2IE = 1;
}



int main()
{

USBCDCDevice cdcDevice;

Setup(display, cdcDevice);
Expand Down Expand Up @@ -589,17 +622,16 @@ int main()

// init_uart2();

uint16_t counter = 0;
InitTimer2();
while (1)
{
cdcDevice.Process();

menuSystem.Update(PollButtons(&cdcDevice), PollKMW(&cdcDevice));

menuSystem.Draw(painter);

counter++;
sprintf(debugText, "%d\r\n", counter);
frames++;
sprintf(debugText, "%d\r\n", fps);
painter->DrawText(3, 90, debugText, (uint16_t)Color565::Red, TextAlign::TEXT_ALIGN_LEFT, 0);

// painter.DrawFillRoundRectangle(50, 120, 100, 40, 5, (uint16_t)Color565::Black);
Expand Down