Exemple #1
0
static int
init_match ( struct ucl_compress *c, struct ucl_swd *s,
	const uint8_t *dict, unsigned int dict_len,
	uint32_t flags )
{
	int r;
	
	assert(!c->init);
	c->init = 1;
	
	s->c = c;
	
	c->last_m_len = c->last_m_off = 0;
	
	c->textsize = c->codesize = c->printcount = 0;
	c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
	c->lazy = 0;
	
	r = swd_init(s,dict,dict_len);
	if (r != UCL_E_OK)
	{
		swd_exit(s);
		return r;
	}
	
	s->use_best_off = (flags & 1) ? 1 : 0;
	return UCL_E_OK;
}
Exemple #2
0
static int
init_match(UCL_COMPRESS_T * c, ucl_swd_t * s,
	   const ucl_byte * dict, ucl_uint dict_len, ucl_uint32 flags)
{
	int     r;

	assert(!c->init);
	c->init = 1;

	s->c = c;

	c->last_m_len = c->last_m_off = 0;

	c->textsize = c->codesize = c->printcount = 0;
	c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
	c->lazy = 0;

	r = swd_init(s, dict, dict_len);
	if (r != UCL_E_OK) {
		swd_exit(s);
		return r;
	}

	s->use_best_off = (flags & 1) ? 1 : 0;
	return UCL_E_OK;
}
Exemple #3
0
static __inline int init_match(UCL_COMPRESS_DATA *c, ucl_swd_t *s, LPBYTE dict, DWORD dict_len, BYTE flags)
{
  s->c = c;
  c->last_m_off = 0;
  c->textsize = c->codesize = c->printcount = 0;
  int r = swd_init(s, dict, dict_len);
  if(r != UCL::E_SUCCESSED)
  {
    swd_exit(s);
    return r;
  }

  return UCL::E_SUCCESSED;
}
Exemple #4
0
/***********************************************************************
//
************************************************************************/
static int init_match(lzo1x_999_t *c, lzo_swd_p s, uint32_t use_best_off)
{
	int r;

	assert(!c->init);
	c->init = 1;

	s->c = c;

	r = swd_init(s);
	if (r != 0)
		return r;

	s->use_best_off = use_best_off;
	return r;
}
Exemple #5
0
tINT init_match (tUCL_COMPRESS_CTX* c, tUCL_SWD* s, tBYTE* dict, 
                 tUINT dict_len, tUINT flags )
{
    int r;

    c->init = 1;
    s->c = c;
    c->last_m_len = c->last_m_off = 0;
    c->textsize = c->codesize = c->printcount = 0;
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
    c->lazy = 0;

    r = swd_init(s,dict,dict_len);
    if (r != UCL_E_OK)
    {
        swd_exit(s);
        return r;
    }

    s->use_best_off = (flags & 1) ? 1 : 0;
    return UCL_E_OK;
}
Exemple #6
0
static int
init_match (lzo1x_999_t * c, lzo1x_999_swd_t * s,
	    const lzo_byte * dict, lzo_uint dict_len, lzo_uint32 flags)
{
	int r;

	c->init = 1;

	s->c = c;

	c->last_m_len = c->last_m_off = 0;

	c->textsize = c->codesize = c->printcount = 0;
	c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
	c->lazy = 0;

	r = swd_init (s, dict, dict_len);
	if (r != 0)
		return r;

	s->use_best_off = (flags & 1) ? 1 : 0;
	return r;
}
Exemple #7
0
int main(void)
{
	setup_hardware();
	GlobalInterruptEnable();

	callsign_init(conf.callsign);

	flash_leds();

	adf_set_power_on(XTAL_FREQ);
	adf_configure();
	adf_set_rx_mode();

	swd_init();
	swd_enable();

	while (1) {
		conf_task();
		rx_task();
		tx_task();
		USB_USBTask();
	}
}
Exemple #8
0
__task void main_task(void) {
    // State processing
    uint16_t flags;

    // LED
    uint8_t dap_led_value = 1;
    uint8_t cdc_led_value = 1;
    uint8_t msd_led_value = 1;

    // USB
    uint32_t usb_state_count;

    // thread running after usb connected started
    uint8_t thread_started = 0;

    // button state
    char button_activated;

    // string containing unique ID
    uint8_t * id_str;

    // Get a reference to this task
    main_task_id = os_tsk_self();

    // leds
    gpio_init();

    usbd_init();
    swd_init();

    // Turn on LED
    gpio_set_dap_led(1);
    gpio_set_cdc_led(1);
    gpio_set_msd_led(1);

    // Setup reset button
    gpio_enable_button_flag(main_task_id, FLAGS_MAIN_RESET);
    button_activated = 1;

    // USB
    usbd_connect(0);
    usb_busy = USB_IDLE;
    usb_busy_count = 0;
    usb_state = USB_CONNECTING;
    usb_state_count = USB_CONNECT_DELAY;

    // Update HTML version information file
    update_html_file();

    // Start timer tasks
    os_tsk_create_user(timer_task_30mS, TIMER_TASK_30_PRIORITY, (void *)stk_timer_30_task, TIMER_TASK_30_STACK);

    // Target running
    target_set_state(RESET_RUN_WITH_DEBUG);

    // start semihost task
    semihost_init();
    semihost_enable();

    while(1) {
        os_evt_wait_or(   FLAGS_MAIN_RESET              // Put target in reset state
                        | FLAGS_MAIN_90MS               // 90mS tick
                        | FLAGS_MAIN_30MS               // 30mS tick
                        | FLAGS_MAIN_POWERDOWN          // Power down interface
                        | FLAGS_MAIN_DISABLEDEBUG       // Power down interface
                        | FLAGS_MAIN_USB_DISCONNECT,    // Disable target debug
                        NO_TIMEOUT);

        // Find out what event happened
        flags = os_evt_get();

        if (flags & FLAGS_MAIN_USB_DISCONNECT) {
            usb_busy = USB_IDLE;                         // USB not busy
            usb_state_count = 4;
            usb_state = USB_DISCONNECT_CONNECT;        // disconnect the usb
        }

        if (flags & FLAGS_MAIN_RESET) {
            cdc_led_state = LED_OFF;
            gpio_set_cdc_led(0);
            //usbd_cdc_ser_flush();
            if (send_uID) {
                // set the target in reset to not receive char on the serial port
                target_set_state(RESET_HOLD);

                // send uid
                id_str = get_uid_string();
                USBD_CDC_ACM_DataSend(id_str, strlen((const char *)id_str));
                send_uID = 0;
            }
            // Reset target
            target_set_state(RESET_RUN);
            cdc_led_state = LED_FLASH;
            gpio_set_cdc_led(1);
            button_activated = 0;
        }

        if (flags & FLAGS_MAIN_POWERDOWN) {
            // Stop semihost task
            semihost_disable();

            // Disable debug
            target_set_state(NO_DEBUG);

            // Disconnect USB
            usbd_connect(0);

            // Turn off LED
            gpio_set_dap_led(0);
            gpio_set_cdc_led(0);
            gpio_set_msd_led(0);

            // TODO: put the interface chip in sleep mode
            while (1) {    }
        }

        if (flags & FLAGS_MAIN_DISABLEDEBUG) {
            // Stop semihost task
            semihost_disable();

            // Disable debug
            target_set_state(NO_DEBUG);
        }

        if (flags & FLAGS_MAIN_90MS) {
            if (!button_activated) {
                gpio_enable_button_flag(main_task_id, FLAGS_MAIN_RESET);
                button_activated = 1;
            }

            // Update USB busy status
            switch (usb_busy) {

                case USB_ACTIVE:
                    if (DECZERO(usb_busy_count) == 0) {
                        usb_busy=USB_IDLE;
                    }
                    break;

                case USB_IDLE:
                default:
                    break;
            }

            // Update USB connect status
            switch (usb_state) {

                case USB_DISCONNECTING:
                    // Wait until USB is idle before disconnecting
                    if (usb_busy == USB_IDLE) {
                        usbd_connect(0);
                        usb_state = USB_DISCONNECTED;
                    }
                    break;

                case USB_DISCONNECT_CONNECT:
                    // Wait until USB is idle before disconnecting
                    if ((usb_busy == USB_IDLE) && (DECZERO(usb_state_count) == 0)) {
                        usbd_connect(0);
                        usb_state = USB_CONNECTING;

                        // Update HTML file
                        update_html_file();
                    }
                    break;

                case USB_CONNECTING:
                    // Wait before connecting
                    if (DECZERO(usb_state_count) == 0) {
                        usbd_connect(1);
                        usb_state = USB_CHECK_CONNECTED;
                    }
                    break;

                case USB_CHECK_CONNECTED:
                    if(usbd_configured()) {
                        if (!thread_started) {
                            os_tsk_create_user(hid_process, DAP_TASK_PRIORITY, (void *)stk_dap_task, DAP_TASK_STACK);
                            serial_task_id = os_tsk_create_user(serial_process, SERIAL_TASK_PRIORITY, (void *)stk_serial_task, SERIAL_TASK_STACK);
                            thread_started = 1;
                        }
                        usb_state = USB_CONNECTED;
                    }
                    break;

                case USB_CONNECTED:
                case USB_DISCONNECTED:
                default:
                    break;
            }
         }

        // 30mS tick used for flashing LED when USB is busy
        if (flags & FLAGS_MAIN_30MS) {
            if (dap_led_usb_activity && ((dap_led_state == LED_FLASH) || (dap_led_state == LED_FLASH_PERMANENT))) {
                // Flash DAP LED ONCE
                if (dap_led_value) {
                    dap_led_value = 0;
                } else {
                    dap_led_value = 1; // Turn on
                    if (dap_led_state == LED_FLASH) {
                        dap_led_usb_activity = 0;
                    }
                }

                // Update hardware
                gpio_set_dap_led(dap_led_value);
            }

            if (msd_led_usb_activity && ((msd_led_state == LED_FLASH) || (msd_led_state == LED_FLASH_PERMANENT))) {
                // Flash MSD LED ONCE
                if (msd_led_value) {
                    msd_led_value = 0;
                } else {
                    msd_led_value = 1; // Turn on
                    if (msd_led_state == LED_FLASH) {
                        msd_led_usb_activity = 0;
                    }
                }

                // Update hardware
                gpio_set_msd_led(msd_led_value);
            }

            if (cdc_led_usb_activity && ((cdc_led_state == LED_FLASH) || (cdc_led_state == LED_FLASH_PERMANENT))) {
                // Flash CDC LED ONCE
                if (cdc_led_value) {
                    cdc_led_value = 0;
                } else {
                    cdc_led_value = 1; // Turn on
                    if (cdc_led_state == LED_FLASH) {
                        cdc_led_usb_activity = 0;
                    }
                }

                // Update hardware
                gpio_set_cdc_led(cdc_led_value);
            }

        }
    }
}
Exemple #9
0
__task void main_task(void) {
    // State processing
    uint16_t flags;

    // LED
    uint8_t dap_led_value = 1;
    uint8_t cdc_led_value = 1;
    uint8_t msd_led_value = 1;

    // USB
    uint32_t usb_state_count;

    // thread running after usb connected started
    uint8_t thread_started = 0;

    // button state
    char button_activated;

    // string containing unique ID
    uint8_t * id_str;

    // Initialize our serial mailbox
    os_mbx_init(&serial_mailbox, sizeof(serial_mailbox));

    // Get a reference to this task
    main_task_id = os_tsk_self();

    // leds
    gpio_init();
    // Turn off LED
    gpio_set_dap_led(1);
    gpio_set_cdc_led(1);
    gpio_set_msd_led(1);

#ifdef BOARD_UBLOX_C027
    PORT_SWD_SETUP();
    // wait until reset output to the target is pulled high
    while (!PIN_nRESET_IN()) {
        /* wait doing nothing */
    }
    os_dly_wait(4);
    // if the reset input from button is low then enter isp programming mode
    if (!(LPC_GPIO->B[19/*RESET_PIN*/ + (1/*RESET_PORT*/ << 5)] & 1)) {
        enter_isp();
    }
#endif 

    usbd_init();
    swd_init();

    // Setup reset button
    gpio_enable_button_flag(main_task_id, FLAGS_MAIN_RESET);
    button_activated = 1;

    // USB
    usbd_connect(0);
    usb_busy = USB_IDLE;
    usb_busy_count = 0;
    usb_state = USB_CONNECTING;
    usb_state_count = USB_CONNECT_DELAY;

    // Update HTML version information file
    update_html_file();

    // Start timer tasks
    os_tsk_create_user(timer_task_30mS, TIMER_TASK_30_PRIORITY, (void *)stk_timer_30_task, TIMER_TASK_30_STACK);

#ifndef BOARD_UBLOX_C027
    // Target running
    //target_set_state(RESET_RUN_WITH_DEBUG);
#endif

#ifdef BOARD_NRF51822AA
    // Target running
    target_set_state(RESET_RUN);
#endif
    // start semihost task
    semihost_init();
    semihost_enable();

    while(1) {
        os_evt_wait_or(   FLAGS_MAIN_RESET              // Put target in reset state
                        | FLAGS_MAIN_90MS               // 90mS tick
                        | FLAGS_MAIN_30MS               // 30mS tick
                        | FLAGS_MAIN_POWERDOWN          // Power down interface
                        | FLAGS_MAIN_DISABLEDEBUG       // Power down interface
#ifdef USE_USB_EJECT_INSERT
                        | FLAGS_MAIN_USB_DISCONNECT     // Disable target debug
                        | FLAGS_MAIN_USB_MEDIA_EJECT,   // Eject file system
#else
                        | FLAGS_MAIN_USB_DISCONNECT,    // Disable target debug
#endif
                        NO_TIMEOUT);

        // Find out what event happened
        flags = os_evt_get();

        if (flags & FLAGS_MAIN_USB_DISCONNECT) {
            usb_busy = USB_IDLE;                         // USB not busy
            usb_state_count = 4;
            usb_state = USB_DISCONNECT_CONNECT;        // disconnect the usb
        }

#ifdef USE_USB_EJECT_INSERT
        if (flags & FLAGS_MAIN_USB_MEDIA_EJECT) {
            EjectInsertMediaMode = EJECT_INSERT_WAIT_TO_EJECT;
            EjectInsertMediaCounter = EJECT_INSERT_DELAY_500MS;
        }
#endif

        if (flags & FLAGS_MAIN_RESET) {
            cdc_led_state = LED_OFF;
            gpio_set_cdc_led(0);
            //usbd_cdc_ser_flush();
            if (send_uID) {
                // set the target in reset to not receive char on the serial port
                target_set_state(RESET_HOLD);

                // send uid
                id_str = get_uid_string();
                USBD_CDC_ACM_DataSend(id_str, strlen((const char *)id_str));
                send_uID = 0;
            }
            // Reset target
            target_set_state(RESET_RUN);
            cdc_led_state = LED_FLASH;
            gpio_set_cdc_led(1);
            button_activated = 0;
        }

        if (flags & FLAGS_MAIN_POWERDOWN) {
            // Stop semihost task
            semihost_disable();

            // Disable debug
            target_set_state(NO_DEBUG);

            // Disconnect USB
            usbd_connect(0);

            // Turn off LED
            gpio_set_dap_led(0);
            gpio_set_cdc_led(0);
            gpio_set_msd_led(0);

            // TODO: put the interface chip in sleep mode
            while (1) {    }
        }

        if (flags & FLAGS_MAIN_DISABLEDEBUG) {
            // Stop semihost task
            semihost_disable();

            // Disable debug
            target_set_state(NO_DEBUG);
        }

        if (flags & FLAGS_MAIN_90MS) {
            if (!button_activated) {
                gpio_enable_button_flag(main_task_id, FLAGS_MAIN_RESET);
                button_activated = 1;
            }

#ifdef USE_USB_EJECT_INSERT
            if (EjectInsertMediaMode == EJECT_INSERT_WAIT_TO_EJECT) {
                if (--EjectInsertMediaCounter == 0) {
                    // Have waited ~0.5 second, time to eject media
                    EjectInsertMediaMode = EJECT_INSERT_WAIT_TO_INSERT;
                    EjectInsertMediaCounter = EJECT_INSERT_DELAY_500MS;
                    USBD_MSC_MediaReady = __FALSE;
                }
            }
            if ((EjectInsertMediaMode == EJECT_INSERT_WAIT_TO_INSERT) && !USBD_MSC_MediaReadyEx) {
                // The host computer have questioned the state and received
                // the message that the media has been removed
                if (--EjectInsertMediaCounter == 0) {
                    // Have waited ~0.5 seconds after ejecting, time to insert media
                    EjectInsertMediaMode = EJECT_INSERT_INACTIVE;
                    USBD_MSC_MediaReady = __TRUE;
                }
            }
#endif

            // Update USB busy status
            switch (usb_busy) {

                case USB_ACTIVE:
                    if (DECZERO(usb_busy_count) == 0) {
                        usb_busy=USB_IDLE;
                    }
                    break;

                case USB_IDLE:
                default:
                    break;
            }

            // Update USB connect status
            switch (usb_state) {

                case USB_DISCONNECTING:
                    // Wait until USB is idle before disconnecting
                    if (usb_busy == USB_IDLE) {
                        usbd_connect(0);
                        usb_state = USB_DISCONNECTED;
                    }
                    break;

                case USB_DISCONNECT_CONNECT:
                    // Wait until USB is idle before disconnecting
                    if ((usb_busy == USB_IDLE) && (DECZERO(usb_state_count) == 0)) {
                        usbd_connect(0);
                        usb_state = USB_CONNECTING;
                        // Update HTML file
                        update_html_file();
						// Delay the connecting state before reconnecting to the host - improved usage with VMs
						usb_state_count = 10; //(90ms * 10 = 900ms)
                    }
                    break;

                case USB_CONNECTING:
                    // Wait before connecting
                    if (DECZERO(usb_state_count) == 0) {
                        usbd_connect(1);
                        usb_state = USB_CHECK_CONNECTED;
                    }
                    break;

                case USB_CHECK_CONNECTED:
                    if(usbd_configured()) {
                        if (!thread_started) {
                            os_tsk_create_user(hid_process, DAP_TASK_PRIORITY, (void *)stk_dap_task, DAP_TASK_STACK);
                            serial_task_id = os_tsk_create_user(serial_process, SERIAL_TASK_PRIORITY, (void *)stk_serial_task, SERIAL_TASK_STACK);
                            thread_started = 1;
                        }
                        usb_state = USB_CONNECTED;
                    }
                    break;

                case USB_CONNECTED:
                case USB_DISCONNECTED:
                default:
                    break;
            }
         }

        // 30mS tick used for flashing LED when USB is busy
        if (flags & FLAGS_MAIN_30MS) {
            if (dap_led_usb_activity && ((dap_led_state == LED_FLASH) || (dap_led_state == LED_FLASH_PERMANENT))) {
                // Flash DAP LED ONCE
                if (dap_led_value) {
                    dap_led_value = 0;
                } else {
                    dap_led_value = 1; // Turn on
                    if (dap_led_state == LED_FLASH) {
                        dap_led_usb_activity = 0;
                    }
                }

                // Update hardware
                gpio_set_dap_led(dap_led_value);
            }

            if (msd_led_usb_activity && ((msd_led_state == LED_FLASH) || (msd_led_state == LED_FLASH_PERMANENT))) {
                // Flash MSD LED ONCE
                if (msd_led_value) {
                    msd_led_value = 0;
                } else {
                    msd_led_value = 1; // Turn on
                    if (msd_led_state == LED_FLASH) {
                        msd_led_usb_activity = 0;
                    }
                }

                // Update hardware
                gpio_set_msd_led(msd_led_value);
            }

            if (cdc_led_usb_activity && ((cdc_led_state == LED_FLASH) || (cdc_led_state == LED_FLASH_PERMANENT))) {
                // Flash CDC LED ONCE
                if (cdc_led_value) {
                    cdc_led_value = 0;
                } else {
                    cdc_led_value = 1; // Turn on
                    if (cdc_led_state == LED_FLASH) {
                        cdc_led_usb_activity = 0;
                    }
                }

                // Update hardware
                gpio_set_cdc_led(cdc_led_value);
            }

        }
    }
}
Exemple #10
0
//! Initialises BDM module for the given target type
//!
//!  @param target = Target processor (see \ref TargetType_t)
//!
uint8_t bdm_setTarget(uint8_t target) {
uint8_t rc = BDM_RC_OK;

#ifdef RESET_IN_PER
   RESET_IN_PER    = 1;     // Needed for input level translation to 5V
#endif
#ifdef RESET_OUT_PER
   RESET_OUT_PER   = 1;     // Holds RESET_OUT inactive when unused
#endif

   if (target == T_OFF) {
	   bdm_off();             // Turn off the interface
   }   
   bdm_interfaceOff();

   rc = bdm_clearStatus();
   if (rc != BDM_RC_OK) {
      return rc;
   }
   cable_status.target_type = target; // Assume mode is valid

   switch (target) {
#if TARGET_CAPABILITY & CAP_S12Z
      case T_HCS12Z  :
#endif
#if (TARGET_CAPABILITY & (CAP_HCS12|CAP_S12Z))   
      case T_HC12:
         bdm_option.useResetSignal = 1; // Must use RESET signal on HC12
         bdmHCS_init();
         break;
#endif         
#if (TARGET_CAPABILITY & CAP_RS08)
      case T_RS08:
#endif
#if (TARGET_CAPABILITY & CAP_HCS08)
      case T_HCS08:
#endif    	  
#if (TARGET_CAPABILITY & CAP_CFV1)
      case T_CFV1:
#endif    	  
#if (TARGET_CAPABILITY & (CAP_RS08|CAP_HCS08|CAP_CFV1))
         bdmHCS_init();
         break;
#endif    	  
#if (TARGET_CAPABILITY&CAP_CFVx)
      case T_CFVx:
         bdm_option.useResetSignal = 1; // Must use RESET signal on CFVx
         bdmcf_init();                  // Initialise the BDM interface
//         (void)bdmcf_resync();          // Synchronise with the target (ignore error?)
         break;
#endif
#if (TARGET_CAPABILITY&CAP_JTAG)
      case T_JTAG:
#endif
#if (TARGET_CAPABILITY&CAP_DSC)
      case T_MC56F80xx:
#endif
#if (TARGET_CAPABILITY&(CAP_JTAG|CAP_DSC))
         bdm_option.useResetSignal = 1; // Must use RESET signal on JTAG etc
         jtag_init();                   // Initialise JTAG
         break;
#endif
#if (TARGET_CAPABILITY&CAP_ARM_JTAG)
      case T_ARM_JTAG:
          jtag_init();                   // Initialise JTAG
          break;
#endif
#if (TARGET_CAPABILITY&CAP_ARM_SWD)
      case T_ARM_SWD:
          swd_init();                   // Initialise JTAG
          break;
#endif
      case T_OFF:
    	  break;
    	  
      default:
         bdm_off();          // Turn off the interface
         (void)bdm_clearStatus();  // Safe mode!
         return BDM_RC_UNKNOWN_TARGET;
   }
   return rc;
}