Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
- extern "C"{
- #include "main.h"
- #include "usb_istr.h"
- #include "usb_pwr.h"
- }
- #include "ch.hpp"
- #include "hal.h"
- using namespace chibios_rt;
- // USB
- uint8_t Send_Buffer[64];
- uint32_t packet_sent=1;
- uint32_t packet_receive=1;
- __IO uint32_t USBConnectTimeOut;
- //usb
- extern __IO uint8_t Receive_Buffer[64];
- extern __IO uint32_t Receive_length ;
- extern __IO uint32_t length ;
- /**
- * @brief Configure the USB.
- * @param None
- * @retval None
- */
- void Demo_USB (void)
- {
- Set_System();
- Set_USBClock();
- USB_Interrupts_Config();
- USB_Init();
- while ((bDeviceState != CONFIGURED)&&(USBConnectTimeOut != 0))
- {}/* */
- }
- class cUsbUartTask : public BaseStaticThread<512> {
- private:
- protected:
- virtual msg_t main(void) {
- setName("cUsbUartTask");
- Demo_USB();
- while (true) {
- /*if (bDeviceState == CONFIGURED)
- {
- CDC_Receive_DATA();
- //Check to see if we have data yet
- if (Receive_length != 0)
- {
- }
- }*/
- }
- sleep(100);
- }
- };
- static cUsbUartTask myUsbTask;
- extern "C"{
- CH_IRQ_HANDLER(Vector8C) {
- }
- CH_IRQ_HANDLER(Vector90) {
- CH_IRQ_PROLOGUE();
- chSysLockFromIsr();
- chSysUnlockFromIsr();
- USB_Istr();
- CH_IRQ_EPILOGUE();
- }
- CH_IRQ_HANDLER(VectorE8)
- {
- CH_IRQ_PROLOGUE();
- chSysLockFromIsr();
- chSysUnlockFromIsr();
- CH_IRQ_EPILOGUE();
- Resume(RESUME_EXTERNAL);
- EXTI_ClearITPendingBit(EXTI_Line18);
- }
- CH_IRQ_HANDLER(HardFaultVector) {
- while(1) {;}
- }
- }
- /*
- * Application entry point.
- */
- int main(void) {
- halInit();
- System::init();
- myUsbTask.start(NORMALPRIO);
- while (true) {
- BaseThread::sleep(MS2ST(500));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment