Archived
1
0

Cleaning up main.c

- main.c is now mostly complete
- Required fixes to matrix.c (some are temporary)
This commit is contained in:
Jacob Alexander 2011-09-30 01:30:34 -07:00
parent c01efa2d53
commit 05c20112e9
4 changed files with 42 additions and 24 deletions

View File

@ -24,9 +24,9 @@
// AVR Includes // AVR Includes
// Project Includes // Project Includes
#include <usb_com.h>
#include <scan_loop.h>
#include <print.h> #include <print.h>
#include <scan_loop.h>
#include <usb_com.h>
// Keymaps // Keymaps
#include <keymap.h> #include <keymap.h>

View File

@ -21,6 +21,9 @@
// ----- Includes ----- // ----- Includes -----
// AVR Includes
#include <avr/io.h>
// Local Includes // Local Includes
#include "matrix.h" #include "matrix.h"
@ -93,9 +96,10 @@ void matrix_pinSetup( uint8_t *matrix )
uint8_t ddrF = 0x00; uint8_t ddrF = 0x00;
// Loop through all the pin assignments, for the initial pin settings // Loop through all the pin assignments, for the initial pin settings
int row, col; //int row, col;
// Rows // Rows
/*
for ( row = 1; row < sizeof(matrix); row++ ) { for ( row = 1; row < sizeof(matrix); row++ ) {
switch ( matrix[row][col] ) { switch ( matrix[row][col] ) {
PIN_CASE(A): PIN_CASE(A):
@ -136,6 +140,7 @@ void matrix_pinSetup( uint8_t *matrix )
continue; continue;
} }
} }
*/
// Setting the pins // Setting the pins
DDRA = ddrA; DDRA = ddrA;
@ -158,6 +163,7 @@ void matrix_scan( uint8_t *matrix, uint8_t *detectArray )
{ {
// Column Scan // Column Scan
#if scanMode == scanCol #if scanMode == scanCol
/*
uint8_t col = 1; uint8_t col = 1;
uint8_t row = 1; uint8_t row = 1;
for ( ; col < sizeof(matrix[1]); col++ ) { for ( ; col < sizeof(matrix[1]); col++ ) {
@ -176,6 +182,7 @@ void matrix_scan( uint8_t *matrix, uint8_t *detectArray )
PIN_TEST_COL(PINF); PIN_TEST_COL(PINF);
} }
} }
*/
#endif #endif
// Row Scan // Row Scan

View File

@ -12,6 +12,7 @@
# #
set( SCAN_SRCS set( SCAN_SRCS
matrix.c
scan_loop.c scan_loop.c
) )

42
main.c
View File

@ -23,18 +23,15 @@
// AVR Includes // AVR Includes
#include <avr/io.h> #include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
// Project Includes // Project Includes
//#include "usb_keys.h" #include <macro.h>
#include "scan_loop.h" #include <scan_loop.h>
//#include "layouts.h" #include <usb_com.h>
//#include "usb_keyboard.h"
#include "usb_keyboard_debug.h" #include <led.h>
#include "print.h" #include <print.h>
#include "led.h"
@ -90,6 +87,7 @@ int main(void)
// Configuring Pins // Configuring Pins
pinSetup(); pinSetup();
init_errorLED();
// Setup USB Module // Setup USB Module
usb_setup(); usb_setup();
@ -101,24 +99,36 @@ int main(void)
TIMSK0 = (1 << TOIE0); TIMSK0 = (1 << TOIE0);
// Main Detection Loop // Main Detection Loop
while ( 1 ) { uint8_t ledTimer = 15; // Enable LED for a short time
//scan_loop(); while ( 1 )
{
// Loop should never get here (indicate error) while ( 1 )
errorLED( 1 ); {
// Acquire Key Indices
// HID Debug Error message scan_loop();
erro_print("Detection loop error, this is very bad...bug report!");
// Send keypresses over USB if the ISR has signalled that it's time // Send keypresses over USB if the ISR has signalled that it's time
if ( !sendKeypresses ) if ( !sendKeypresses )
continue; continue;
// Run Macros over Key Indices and convert to USB Keys
process_macros();
// Send USB Data // Send USB Data
usb_send(); usb_send();
// Clear sendKeypresses Flag // Clear sendKeypresses Flag
sendKeypresses = 0; sendKeypresses = 0;
// Indicate Error, if valid
errorLED( ledTimer );
}
// Loop should never get here (indicate error)
ledTimer = 255;
// HID Debug Error message
erro_print("Detection loop error, this is very bad...bug report!");
} }
} }