日食撮像システム 2019年 Ver.
USB-PIC:ファームウェア6歩目・緊急時スイッチ対応型
22.Dec.2018製作
モバイルバッテリ駆動では緊急時スイッチが使えない!
 PCと接続している時にUSB-PICの緊急時スイッチ/タイマーリモコン接点は使えましたが、モバイルバッテリとUSB-PICの組み合わせでは動作しませんでした。いろいろ試したけどダメ…で、ふとmain.cに書き込めばいい、と感づき緊急時スイッチの信号を感知しシーケンスを実行するように変更したところきちんと動きました。という事で、書き加えたmain.cもダウンロード出来るようにしました。

 ちなみに2016年版のMLAを使っています。他の年のもので上手く使えるかはわかりません…
キヤノン対応のタイマーリモコンを使う場合の問題
 スイッチになっているのはステレオプラグの一番根本と真ん中の端子部分だけです。なのでそれに対応したステレオジャックの配線にしないといけません。
     
  「app_device_cdc_basic.c」の中身・ダウンロードはこちらからD.L.
「main.c」の中身・ダウンロードはこちらからD.L.
USB-PICに書き込むファームウェア
  1 /*******************************************************************************
  2 Copyright 2016 Microchip Technology Inc. (www.microchip.com)
  3 
  4 Licensed under the Apache License, Version 2.0 (the "License");
  5 you may not use this file except in compliance with the License.
  6 You may obtain a copy of the License at
  7 
  8     http://www.apache.org/licenses/LICENSE-2.0
  9 
 10 Unless required by applicable law or agreed to in writing, software
 11 distributed under the License is distributed on an "AS IS" BASIS,
 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 See the License for the specific language governing permissions and
 14 limitations under the License.
 15 
 16 To request to license the code under the MLA license (www.microchip.com/mla_license), 
 17 please contact mla_licensing@microchip.com
 18 *******************************************************************************/
 19 
 20 /** INCLUDES *******************************************************/
 21 #include "system.h"
 22 
 23 #include "app_device_cdc_basic.h"
 24 #include "app_led_usb_status.h"
 25 
 26 #include "usb.h"
 27 #include "usb_device.h"
 28 #include "usb_device_cdc.h"
 29 
 30 /********************************************************************
 31  * Function:        void main(void)
 32  *
 33  * PreCondition:    None
 34  *
 35  * Input:           None
 36  *
 37  * Output:          None
 38  *
 39  * Side Effects:    None
 40  *
 41  * Overview:        Main program entry point.
 42  *
 43  * Note:            None
 44  *******************************************************************/
 45 #define _XTAL_FREQ 48000000
 46 MAIN_RETURN main(void)
 47 {
 48     int i;
 49     
 50     SYSTEM_Initialize(SYSTEM_STATE_USB_START);
 51 
 52     USBDeviceInit();
 53     USBDeviceAttach();
 54     void USB_PIC_Cont_1st2();
 55 void USB_PIC_Cont_2nd2();
 56 void USB_PIC_BKT_Down2();
 57 void USB_PIC_BKT_Up2();
 58 void Captor();
 59 void SpeedUp();
 60 void SpeedDown();
 61 void Filter_Open();
 62 void Filter_Close();
 63 void PIC2_Cont();
 64 void PIC1_Start();
 65 void PIC2_Int();
 66 
 67     while(1)
 68     {
 69         
 70         if (RA3 == 0)
 71         {
 72             Filter_Open();
 73             PIC2_Cont();
 74             USB_PIC_Cont_1st2();
 75             PIC1_Start();
 76             for(i=1; i<=4; i++)
 77             {
 78                 USB_PIC_BKT_Down2();
 79                 USB_PIC_BKT_Up2();
 80             }
 81             __delay_ms(1000);
 82             USB_PIC_Cont_2nd2();
 83             PIC2_Int();
 84             Filter_Close();
 85         }
 86         
 87         SYSTEM_Tasks();
 88 
 89         #if defined(USB_POLLING)
 90             // Interrupt or polling method.  If using polling, must call
 91             // this function periodically.  This function will take care
 92             // of processing and responding to SETUP transactions
 93             // (such as during the enumeration process when you first
 94             // plug in).  USB hosts require that USB devices should accept
 95             // and process SETUP packets in a timely fashion.  Therefore,
 96             // when using polling, this function should be called
 97             // regularly (such as once every 1.8ms or faster** [see
 98             // inline code comments in usb_device.c for explanation when
 99             // "or faster" applies])  In most cases, the USBDeviceTasks()
100             // function does not take very long to execute (ex: <100
101             // instruction cycles) before it returns.
102             USBDeviceTasks();
103         #endif
104 
105         //Application specific tasks
106         APP_DeviceCDCBasicDemoTasks();
107 
108     }//end while
109 }//end main
110 
111 /*******************************************************************************
112  End of File
113 */
114 
inserted by FC2 system