Initial code for USB cable detection
- Currently actual detection commented out due to issues
This commit is contained in:
parent
762e75d875
commit
9e3d3aaca4
@ -1098,12 +1098,17 @@ restart:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void usb_init()
|
uint8_t usb_init()
|
||||||
{
|
{
|
||||||
#ifdef UART_DEBUG
|
#ifdef UART_DEBUG
|
||||||
print("USB INIT"NL);
|
print("USB INIT"NL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// If no USB cable is attached, do not initialize usb
|
||||||
|
// XXX Test -HaaTa
|
||||||
|
//if ( USB0_OTGISTAT & USB_OTGSTAT_ID )
|
||||||
|
// return 0;
|
||||||
|
|
||||||
// Clear out endpoints table
|
// Clear out endpoints table
|
||||||
for ( int i = 0; i <= NUM_ENDPOINTS * 4; i++ )
|
for ( int i = 0; i <= NUM_ENDPOINTS * 4; i++ )
|
||||||
{
|
{
|
||||||
@ -1147,6 +1152,8 @@ void usb_init()
|
|||||||
|
|
||||||
// enable d+ pullup
|
// enable d+ pullup
|
||||||
USB0_CONTROL = USB_CONTROL_DPPULLUPNONOTG;
|
USB0_CONTROL = USB_CONTROL_DPPULLUPNONOTG;
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return 0 if the USB is not configured, or the configuration
|
// return 0 if the USB is not configured, or the configuration
|
||||||
|
@ -61,8 +61,8 @@ extern volatile uint8_t usb_cdc_transmit_flush_timer;
|
|||||||
// ----- Functions -----
|
// ----- Functions -----
|
||||||
|
|
||||||
uint8_t usb_configured(); // is the USB port configured
|
uint8_t usb_configured(); // is the USB port configured
|
||||||
|
uint8_t usb_init(); // Returns 1 on success, 0 if no cable is attached
|
||||||
|
|
||||||
void usb_init();
|
|
||||||
void usb_isr();
|
void usb_isr();
|
||||||
void usb_tx( uint32_t endpoint, usb_packet_t *packet );
|
void usb_tx( uint32_t endpoint, usb_packet_t *packet );
|
||||||
void usb_tx_isr( uint32_t endpoint, usb_packet_t *packet );
|
void usb_tx_isr( uint32_t endpoint, usb_packet_t *packet );
|
||||||
|
@ -590,8 +590,13 @@ void wdt_init()
|
|||||||
|
|
||||||
|
|
||||||
// initialize USB
|
// initialize USB
|
||||||
void usb_init()
|
uint8_t usb_init()
|
||||||
{
|
{
|
||||||
|
// Check to see if a usb cable has been plugged in
|
||||||
|
// XXX Not tested (also, not currently needed) -HaaTa
|
||||||
|
//if ( USB0_STAT & (1 << 1)
|
||||||
|
// return 0;
|
||||||
|
|
||||||
HW_CONFIG();
|
HW_CONFIG();
|
||||||
USB_FREEZE(); // enable USB
|
USB_FREEZE(); // enable USB
|
||||||
PLL_CONFIG(); // config PLL
|
PLL_CONFIG(); // config PLL
|
||||||
@ -604,6 +609,8 @@ void usb_init()
|
|||||||
|
|
||||||
// Disable watchdog timer after possible software reset
|
// Disable watchdog timer after possible software reset
|
||||||
//wdt_init(); // XXX Not working...seems to be ok without this, not sure though
|
//wdt_init(); // XXX Not working...seems to be ok without this, not sure though
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return 0 if the USB is not configured, or the configuration
|
// return 0 if the USB is not configured, or the configuration
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
// ----- Function Declarations -----
|
// ----- Function Declarations -----
|
||||||
|
|
||||||
// Basic USB Configuration
|
// Basic USB Configuration
|
||||||
void usb_init(); // initialize everything
|
uint8_t usb_init(); // initialize everything
|
||||||
uint8_t usb_configured(); // is the USB port configured
|
uint8_t usb_configured(); // is the USB port configured
|
||||||
|
|
||||||
// Keyboard HID Functions
|
// Keyboard HID Functions
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2011-2014 by Jacob Alexander
|
/* Copyright (C) 2011-2015 by Jacob Alexander
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -124,6 +124,11 @@ USBKeyChangeState USBKeys_Changed = USBKeyChangeState_None;
|
|||||||
// count until idle timeout
|
// count until idle timeout
|
||||||
uint8_t USBKeys_Idle_Count = 0;
|
uint8_t USBKeys_Idle_Count = 0;
|
||||||
|
|
||||||
|
// Indicates whether the Output module is fully functional
|
||||||
|
// 0 - Not fully functional, 1 - Fully functional
|
||||||
|
// 0 is often used to show that a USB cable is not plugged in (but has power)
|
||||||
|
uint8_t Output_Available = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----- Capabilities -----
|
// ----- Capabilities -----
|
||||||
@ -473,9 +478,11 @@ inline void Output_setup()
|
|||||||
{
|
{
|
||||||
// Initialize the USB, and then wait for the host to set configuration.
|
// Initialize the USB, and then wait for the host to set configuration.
|
||||||
// This will hang forever if USB does not initialize
|
// This will hang forever if USB does not initialize
|
||||||
usb_init();
|
// If no USB cable is attached, does not try and initialize USB
|
||||||
|
if ( usb_init() )
|
||||||
while ( !usb_configured() );
|
{
|
||||||
|
while ( !usb_configured() );
|
||||||
|
}
|
||||||
|
|
||||||
// Register USB Output CLI dictionary
|
// Register USB Output CLI dictionary
|
||||||
CLI_registerDictionary( outputCLIDict, outputCLIDictName );
|
CLI_registerDictionary( outputCLIDict, outputCLIDictName );
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2013-2014 by Jacob Alexander
|
/* Copyright (C) 2013-2015 by Jacob Alexander
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -79,6 +79,8 @@ extern uint8_t USBKeys_Idle_Count;
|
|||||||
|
|
||||||
extern USBKeyChangeState USBKeys_Changed;
|
extern USBKeyChangeState USBKeys_Changed;
|
||||||
|
|
||||||
|
extern uint8_t Output_Available; // 0 - Output module not fully functional, 1 - Output module working
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----- Capabilities -----
|
// ----- Capabilities -----
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2014 by Jacob Alexander
|
/* Copyright (C) 2014-2015 by Jacob Alexander
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -107,6 +107,11 @@ USBKeyChangeState USBKeys_Changed = USBKeyChangeState_None;
|
|||||||
// count until idle timeout
|
// count until idle timeout
|
||||||
uint8_t USBKeys_Idle_Count = 0;
|
uint8_t USBKeys_Idle_Count = 0;
|
||||||
|
|
||||||
|
// Indicates whether the Output module is fully functional
|
||||||
|
// 0 - Not fully functional, 1 - Fully functional
|
||||||
|
// 0 is often used to show that a USB cable is not plugged in (but has power)
|
||||||
|
uint8_t Output_Available = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----- Capabilities -----
|
// ----- Capabilities -----
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2013-2014 by Jacob Alexander
|
/* Copyright (C) 2013-2015 by Jacob Alexander
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -76,6 +76,8 @@ extern uint8_t USBKeys_Idle_Count;
|
|||||||
|
|
||||||
extern USBKeyChangeState USBKeys_Changed;
|
extern USBKeyChangeState USBKeys_Changed;
|
||||||
|
|
||||||
|
extern uint8_t Output_Available; // 0 - Output module not fully functional, 1 - Output module working
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----- Capabilities -----
|
// ----- Capabilities -----
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2014 by Jacob Alexander
|
/* Copyright (C) 2014-2015 by Jacob Alexander
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -33,10 +33,10 @@
|
|||||||
// USB Includes
|
// USB Includes
|
||||||
#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
|
#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
|
||||||
#elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_)
|
#elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_)
|
||||||
#include "../uartOut/arm/uart_serial.h"
|
#include <uartOut/arm/uart_serial.h>
|
||||||
#include "../pjrcUSB/arm/usb_dev.h"
|
#include <pjrcUSB/arm/usb_dev.h>
|
||||||
#include "../pjrcUSB/arm/usb_keyboard.h"
|
#include <pjrcUSB/arm/usb_keyboard.h>
|
||||||
#include "../pjrcUSB/arm/usb_serial.h"
|
#include <pjrcUSB/arm/usb_serial.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Local Includes
|
// Local Includes
|
||||||
@ -130,6 +130,11 @@ USBKeyChangeState USBKeys_Changed = USBKeyChangeState_None;
|
|||||||
// count until idle timeout
|
// count until idle timeout
|
||||||
uint8_t USBKeys_Idle_Count = 0;
|
uint8_t USBKeys_Idle_Count = 0;
|
||||||
|
|
||||||
|
// Indicates whether the Output module is fully functional
|
||||||
|
// 0 - Not fully functional, 1 - Fully functional
|
||||||
|
// 0 is often used to show that a USB cable is not plugged in (but has power)
|
||||||
|
uint8_t Output_Available = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----- Capabilities -----
|
// ----- Capabilities -----
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2013-2014 by Jacob Alexander
|
/* Copyright (C) 2013-2015 by Jacob Alexander
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -78,6 +78,8 @@ extern uint8_t USBKeys_Idle_Count;
|
|||||||
|
|
||||||
extern USBKeyChangeState USBKeys_Changed;
|
extern USBKeyChangeState USBKeys_Changed;
|
||||||
|
|
||||||
|
extern uint8_t Output_Available; // 0 - Output module not fully functional, 1 - Output module working
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----- Capabilities -----
|
// ----- Capabilities -----
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
###| CMake Kiibohd Controller Scan Module |###
|
###| CMake Kiibohd Controller Scan Module |###
|
||||||
#
|
#
|
||||||
# Written by Jacob Alexander in 2014 for the Kiibohd Controller
|
# Written by Jacob Alexander in 2014-2015 for the Kiibohd Controller
|
||||||
#
|
#
|
||||||
# Released into the Public Domain
|
# Released into the Public Domain
|
||||||
#
|
#
|
||||||
@ -8,27 +8,24 @@
|
|||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# Module C files
|
# Required Sub-modules
|
||||||
#
|
#
|
||||||
|
AddModule ( Scan ISSILed )
|
||||||
set( SCAN_SRCS
|
AddModule ( Scan MatrixARM )
|
||||||
scan_loop.c
|
|
||||||
../MatrixARM/matrix_scan.c
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# Module Specific Options
|
# Module C files
|
||||||
#
|
#
|
||||||
add_definitions(
|
set( Module_SRCS
|
||||||
-I${HEAD_DIR}/Scan/MatrixARM
|
scan_loop.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# Compiler Family Compatibility
|
# Compiler Family Compatibility
|
||||||
#
|
#
|
||||||
set( ScanModuleCompatibility
|
set( ModuleCompatibility
|
||||||
arm
|
arm
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user