static void system_config_handler(const msg_lvl2_t * msg) {
    pmd_net_sys_config_data_t cd;
    cd.config = NULL;
    cd.section = NULL;

    if(pmd_net_sys_config_read_data(&(msg->data), &cd) == 0) {
        switch(cd.operation) {
        case PMD_NET_SYS_CONFIG_FULL:
            led1_blink(4, 50);
            config_full_handler(&cd);
            break;

        case PMD_NET_SYS_CONFIG_REQUEST:
            led2_blink(1, 100);
            config_request_handler();
            break;

        case PMD_NET_SYS_CONFIG_SECTION_ADD:
            led1_blink(1, 50);
            config_section_add_handler(&cd);
            break;

        case PMD_NET_SYS_CONFIG_SECTION_DEL:
            led1_blink(2, 50);
            config_section_del_handler(&cd);
            break;
        }
    }

    if(cd.config != NULL) {
        free(cd.config);
        cd.config = NULL;
    }
}
Example #2
0
//
//	PCから仮想COMポート側へデータを送信する.
//
void EP3_OUT_Callback(void)
{
	uint16_t USB_Rx_Cnt;

#if	LED_DEBUG
	led2_blink(0);
#endif


	/* Get the received data buffer and update the counter */
	USB_Rx_Cnt = USB_SIL_Read(EP3_OUT, USB_Rx_Buffer);

	/* USB data will be immediately processed, this allow next USB traffic beeing
	NAKed till the end of the USART Xfet */
	USBenqueue(USB_Rx_Buffer, USB_Rx_Cnt);
//	if(USB_Rx_Cnt) led2_blink(0);

#ifndef STM32F10X_CL
	if(	USBgetfreesize() >= 64 ) {
		/* Enable the receive of data on EP3 */
		SetEPRxValid(ENDP3);
		flag_EP3_OUT_PENDING=0;
	}else{
		// 受信バッファの空きがないときは一旦ペンディングする.
		flag_EP3_OUT_PENDING=1;
	}
#endif /* STM32F10X_CL */
}
Example #3
0
//
//	仮想COMポートからのデータをPC側に返送する.
//
void EP1_IN_Callback (void)
{
#if	0
	if(	GetEPTxStatus(ENDP1) == EP_TX_VALID) return;

	int Recv_Size = USART_RecvData(Recv_Buffer);
	if(	Recv_Size ) {
		UserToPMABufferCopy(Recv_Buffer, ENDP1_TXADDR, Recv_Size);
		SetEPTxCount(ENDP1, Recv_Size);
		SetEPTxValid(ENDP1);
	}
#if	LED_DEBUG
	led2_blink(0);
#endif
#endif
	countTx = 0;
}
Example #4
0
void EP1_IN_Callback (void)
{
	uint16_t USB_Tx_ptr;
	uint16_t USB_Tx_length;

#if	LED_DEBUG
	led2_blink(0);
#endif

	if (USB_Tx_State == 1) {
		if (USART_Rx_length == 0) {
			USB_Tx_State = 0;
		} else {
			if (USART_Rx_length > VIRTUAL_COM_PORT_DATA_SIZE) {
				USB_Tx_ptr = USART_Rx_ptr_out;
				USB_Tx_length = VIRTUAL_COM_PORT_DATA_SIZE;

				USART_Rx_ptr_out += VIRTUAL_COM_PORT_DATA_SIZE;
				USART_Rx_length -= VIRTUAL_COM_PORT_DATA_SIZE;
			} else {
				USB_Tx_ptr = USART_Rx_ptr_out;
				USB_Tx_length = USART_Rx_length;

				USART_Rx_ptr_out += USART_Rx_length;
				USART_Rx_length = 0;
			}

#ifdef USE_STM3210C_EVAL
			USB_SIL_Write(EP1_IN, &USART_Rx_Buffer[USB_Tx_ptr], USB_Tx_length);
#else
			UserToPMABufferCopy(&USART_Rx_Buffer[USB_Tx_ptr], ENDP1_TXADDR, USB_Tx_length);
			SetEPTxCount(ENDP1, USB_Tx_length);
			SetEPTxValid(ENDP1);
#endif
		}
	}
}