Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • fix/macos-meta-files-in-menu
  • koalo/bhi160
  • genofire/ble-rewrite
  • rahix/simple_menu
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • ios-workarounds
  • koalo/wip/i2c-for-python
  • renze/safe_mode
  • renze/hatchery_apps
  • schneider/fundamental-test
  • koalo/factory-reset
  • msgctl/gfx_rle
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • schneider/bonding
  • schneider/bootloader-update-9a0d158
  • schneider/bsec
  • rahix/bma
  • v1.12
  • v1.11
  • v1.10
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
36 results

cdcacm.c

Blame
  • Forked from card10 / firmware
    590 commits behind the upstream repository.
    cdcacm.c 2.88 KiB
    /**
     * 
     * epicardium-specific implemnetation of cdcacm device
     * services CDCACM API
     */
    
    #include "usb/epc_usb.h"
    #include "usb/cdcacm.h"
    #include "usb/descriptors.h"
    
    #include <stdio.h>
    #include <stddef.h>
    #include <errno.h>
    
    #include "usb.h"
    #include "usb_event.h"
    #include "cdc_acm.h"
    
    #include "modules/log.h"
    #include "modules/modules.h"
    
    #include "FreeRTOS.h"
    #include "task.h"
    
    static volatile int lockup_disable = 0;
    
    static inline struct config_descriptor_cdcacm *
    descriptors(struct esb_config *self)
    {
    	return self->descriptors->cdcacm;
    }
    
    /******************************************************************************/
    static volatile int usb_read_complete; // SWYM: only ever written to
    static int cb_acm_read_ready(void)
    {
    	usb_read_complete = 1;
    	return 0;
    }
    
    static int cb_acm_connected(void)
    {
    	lockup_disable = 0;
    	return 0;
    }
    
    int esb_cdc_init(struct esb_config *self)
    {
    	LOG_DEBUG("cdcacm", "init");
    	struct config_descriptor_cdcacm *dsc = descriptors(self);
    	usb_read_complete                    = 0;
    
    	int ret = acm_init(&dsc->comm_interface);
    	acm_register_callback(
    		ACM_CB_READ_READY,
    		cb_acm_read_ready); //SWYM: actually not needed
    	acm_register_callback(ACM_CB_CONNECTED, cb_acm_connected);
    	return ret;
    }
    
    int esb_cdc_configure(struct esb_config *self)
    {
    	struct config_descriptor_cdcacm *dsc = descriptors(self);
    
    	//acm_configure does not keep the amc_cfg_t pointer around
    	//so stack-local lifetime is fine
    	acm_cfg_t acm_cfg = {
    		.in_ep         = dsc->endpoint_in.bEndpointAddress & 0x0f,
    		.in_maxpacket  = MXC_USBHS_MAX_PACKET,
    		.out_ep        = dsc->endpoint_out.bEndpointAddress,