2014-01-22 08:38:53 +00:00
/* Copyright (C) 2011-2014 by Jacob Alexander
*
2011-03-04 00:38:32 +00:00
* Permission is hereby granted , free of charge , to any person obtaining a copy
* of this software and associated documentation files ( the " Software " ) , to deal
* in the Software without restriction , including without limitation the rights
* to use , copy , modify , merge , publish , distribute , sublicense , and / or sell
* copies of the Software , and to permit persons to whom the Software is
* furnished to do so , subject to the following conditions :
2014-01-22 08:38:53 +00:00
*
2011-03-04 00:38:32 +00:00
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software .
2014-01-22 08:38:53 +00:00
*
2011-03-04 00:38:32 +00:00
* THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR
* IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY ,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER
* LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM ,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE .
*/
2011-09-30 05:22:19 +00:00
// ----- Includes -----
2013-01-26 20:05:28 +00:00
// Compiler Includes
# include <Lib/MainLib.h>
2011-09-30 05:22:19 +00:00
// Project Includes
2011-09-30 08:30:34 +00:00
# include <macro.h>
# include <scan_loop.h>
2014-01-20 00:54:58 +00:00
# include <output_com.h>
2011-03-10 06:49:34 +00:00
2014-01-22 08:38:53 +00:00
# include <cli.h>
2011-09-30 08:30:34 +00:00
# include <led.h>
# include <print.h>
2011-03-04 00:38:32 +00:00
2011-03-17 05:43:33 +00:00
2011-09-30 05:22:19 +00:00
// ----- Functions -----
2014-07-01 06:52:24 +00:00
int main ( )
2013-01-26 20:05:28 +00:00
{
2014-09-20 03:48:31 +00:00
// AVR - Teensy Set Clock speed to 16 MHz
# if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
CLKPR = 0x80 ;
CLKPR = 0x00 ;
# endif
2014-01-20 00:54:58 +00:00
// Enable CLI
2014-04-06 18:49:27 +00:00
CLI_init ( ) ;
2011-03-04 00:38:32 +00:00
2014-04-06 18:49:27 +00:00
// Setup Modules
Output_setup ( ) ;
Macro_setup ( ) ;
2014-04-13 04:13:37 +00:00
Scan_setup ( ) ;
2014-03-31 08:07:48 +00:00
2011-03-04 00:38:32 +00:00
// Main Detection Loop
2011-09-30 08:30:34 +00:00
while ( 1 )
{
2014-03-31 08:07:48 +00:00
// Process CLI
2014-04-06 18:49:27 +00:00
CLI_process ( ) ;
2011-09-30 05:22:19 +00:00
2014-03-31 08:07:48 +00:00
// Acquire Key Indices
// Loop continuously until scan_loop returns 0
cli ( ) ;
2014-04-17 07:11:36 +00:00
while ( Scan_loop ( ) ) ;
2014-03-31 08:07:48 +00:00
sei ( ) ;
2011-09-30 05:22:19 +00:00
2014-03-31 08:07:48 +00:00
// Run Macros over Key Indices and convert to USB Keys
2014-04-06 18:49:27 +00:00
Macro_process ( ) ;
2011-10-01 07:54:18 +00:00
2014-09-20 02:33:20 +00:00
// Sends USB data only if changed
2014-04-06 18:49:27 +00:00
Output_send ( ) ;
2011-03-17 05:43:33 +00:00
}
}