| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- #include "usbapp/usb_application_power.h"
- #include "usb/usb_bridge.h"
- #include "usb/usb_config.h"
- #include "usbd_vendor.h"
- #include "core/csect.h"
- #include "core/config.h"
- #include "app/nfm/nfm_base.h"
- #include "app/led/led.h"
- #include "drivers/power_management/power_management.h"
- #define PROTO_REQ_SET_VBUS_POWER_SWITCH 0x1A // âêëþ÷èòü/âûêëþ÷èòü ïèòàíèå ïî ëèíèè VBUS
- #define PROTO_REQ_SET_28_POWER_SWITCH 0x1B // âêëþ÷èòü/âûêëþ÷èòü ïèòàíèå ïî ëèíèè 28 âîëüò
- #define PROTO_REQ_SET_EXT_POWER_SWITCH 0x1C // âêëþ÷èòü/âûêëþ÷èòü ïèòàíèå ïî ëèíèè EXT
- #define PROTO_REQ_SET_AMP_POWER_SWITCH 0x1E // âêëþ÷èòü/âûêëþ÷èòü ïèòàíèå ïî ëèíèè AMP
- #define PROTO_REQ_GET_28_POWER_VALUE 0x1D // ñ÷èòàòü çíà÷åíèå íàïðÿæåíèÿ ëèíèè 28 âîëüò
- #define PROTO_REQ_WIDX_AMP1_POWER_MODE 0x0A // âêëþ÷èòü/âûêëþ÷èòü ïèòàíèå ïî ëèíèè AMP1
- #define PROTO_REQ_WIDX_AMP2_POWER_MODE 0x0B // âêëþ÷èòü/âûêëþ÷èòü ïèòàíèå ïî ëèíèè AMP2
- #define PROTO_REQ_WIDX_AMP3_POWER_MODE 0x0C // âêëþ÷èòü/âûêëþ÷èòü ïèòàíèå ïî ëèíèè AMP3
- static int8_t fPowerAppInit();
- static int8_t fPowerAppDeInit();
- static void fPowerAppReset();
- static bool fPowerAppSetup( const tUSBSetupPacket_t * pSetup, bool bFirstStage, bool success );
- static size_t fPowerAppControlRx( const tUSBSetupPacket_t * pSetup, sUSBTransfer_t * tx, size_t idx, size_t bytesRemaining );
- static size_t fPowerAppControlTx( const tUSBSetupPacket_t * pSetup, sUSBTransfer_t * rx, size_t idx, size_t bytesRemaining );
- const sUSBAppEntry_Control_t usbapplication_ACM_planarproto_power = {
- .fUsbInit = fPowerAppInit,
- .fUsbDeInit = fPowerAppDeInit,
- .fUsbSetup = fPowerAppSetup,
- .fUsbCtlEpRx = fPowerAppControlRx,
- .fUsbCtlEpTx = fPowerAppControlTx,
- .fResetEvent = fPowerAppReset,
- };
- //-----------------------------------------------------
- // &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&&
- static int8_t fPowerAppInit()
- {
- return 0;
- }
- // &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ----
- static int8_t fPowerAppDeInit()
- {
- return 0;
- }
- // &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ----
- static void fPowerAppReset()
- {
- }
- // &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ----
- static bool fPowerAppSetup( const tUSBSetupPacket_t * pSetup, bool bFirstStage, bool success )
- {
- switch ( pSetup->bRequest )
- {
- case PROTO_REQ_SET_28_POWER_SWITCH:
- {
- return true;
- }
- break;
-
- case PROTO_REQ_GET_28_POWER_VALUE:
- {
- return true;
- }
-
- case PROTO_REQ_SET_VBUS_POWER_SWITCH:
- {
- //VBUS(pSetup->wValue);
- return true;
- }
- break;
-
- case PROTO_REQ_SET_EXT_POWER_SWITCH:
- {
- //EXT_PWR(pSetup->wValue);
- return true;
- }
- break;
-
- case PROTO_REQ_SET_AMP_POWER_SWITCH:
- {
- // switch(pSetup->wIndex)
- // {
- // case PROTO_REQ_WIDX_AMP1_POWER_MODE:
- // {
- // AMP_PWR(pSetup->wValue, AMP1);
- // return true;
- // }
- // break;
- // case PROTO_REQ_WIDX_AMP2_POWER_MODE:
- // {
- // AMP_PWR(pSetup->wValue, AMP2);
- // return true;
- // }
- // break;
- // case PROTO_REQ_WIDX_AMP3_POWER_MODE:
- // {
- // AMP_PWR(pSetup->wValue, AMP3);
- // return true;
- // }
- // break;
- // }
- }
- break;
- }
- return false;
- }
- // &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ----
- static size_t fPowerAppControlRx( const tUSBSetupPacket_t * pSetup, sUSBTransfer_t * rx, size_t idx, size_t bytesRemaining )
- {
- return 0;
- }
- // &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ---- &&&& ----
- static size_t fPowerAppControlTx( const tUSBSetupPacket_t * pSetup, sUSBTransfer_t * tx, size_t idx, size_t bytesRemaining )
- {
- // switch ( pSetup->bRequest )
- // {
- // case PROTO_REQ_GET_28_POWER_VALUE:
- // {
- // float external_voltage = (float)PMHandle.PM_GetAdcPowerValue()/100;
- // if( 0 == idx && sizeof(external_voltage) == bytesRemaining )
- // {
- // usb_push_transfer( tx, &external_voltage, sizeof(external_voltage) );
- // }
- // }
- // break;
- // }
- return usb_count_transfer( tx );
- }
|