void cdc_set_line_coding (void) { Usb_ack_setup_received_free(); while(!Is_usb_control_out_received()); Usb_reset_endpoint_fifo_access(EP_CONTROL); LSB0(line_coding.dwDTERate) = Usb_read_endpoint_data(EP_CONTROL, 8); LSB1(line_coding.dwDTERate) = Usb_read_endpoint_data(EP_CONTROL, 8); LSB2(line_coding.dwDTERate) = Usb_read_endpoint_data(EP_CONTROL, 8); LSB3(line_coding.dwDTERate) = Usb_read_endpoint_data(EP_CONTROL, 8); line_coding.bCharFormat = Usb_read_endpoint_data(EP_CONTROL, 8); line_coding.bParityType = Usb_read_endpoint_data(EP_CONTROL, 8); line_coding.bDataBits = Usb_read_endpoint_data(EP_CONTROL, 8); Usb_ack_control_out_received_free(); Usb_ack_control_in_ready_send(); while (!Is_usb_control_in_ready()); // Set the baudrate of the USART { static usart_options_t dbg_usart_options; uint32_t stopbits, parity; if ( line_coding.bCharFormat==0 ) stopbits = USART_1_STOPBIT; else if( line_coding.bCharFormat==1 ) stopbits = USART_1_5_STOPBITS; else stopbits = USART_2_STOPBITS; if ( line_coding.bParityType==0 ) parity = USART_NO_PARITY; else if( line_coding.bParityType==1 ) parity = USART_ODD_PARITY; else if( line_coding.bParityType==2 ) parity = USART_EVEN_PARITY; else if( line_coding.bParityType==3 ) parity = USART_MARK_PARITY; else parity = USART_SPACE_PARITY; // Options for debug USART. dbg_usart_options.baudrate = line_coding.dwDTERate; dbg_usart_options.charlength = line_coding.bDataBits; dbg_usart_options.paritytype = parity; dbg_usart_options.stopbits = stopbits; dbg_usart_options.channelmode = USART_NORMAL_CHMODE; // Initialize it in RS232 mode. usart_init_rs232(DBG_USART, &dbg_usart_options, pcl_freq_param.pba_f); // Enable Rx interrupts DBG_USART->ier = AVR32_USART_IER_RXRDY_MASK; } }
//! cdc_set_line_coding. //! //! @brief This function manages reception of line coding parameters (baudrate...). //! void cdc_set_line_coding (void) { Usb_ack_receive_setup(); while (!(Is_usb_receive_out())); LSB0(line_coding.dwDTERate) = Usb_read_byte(); LSB1(line_coding.dwDTERate) = Usb_read_byte(); LSB2(line_coding.dwDTERate) = Usb_read_byte(); LSB3(line_coding.dwDTERate) = Usb_read_byte(); line_coding.bCharFormat = Usb_read_byte(); line_coding.bParityType = Usb_read_byte(); line_coding.bDataBits = Usb_read_byte(); Usb_ack_receive_out(); Usb_send_control_in(); // send a ZLP for STATUS phase while(!(Is_usb_read_control_enabled())); }
//! cdc_get_line_coding. //! //! @brief This function manages reception of line coding parameters (baudrate...). //! void cdc_get_line_coding(void) { Usb_ack_receive_setup(); Usb_write_byte(LSB0(line_coding.dwDTERate)); Usb_write_byte(LSB1(line_coding.dwDTERate)); Usb_write_byte(LSB2(line_coding.dwDTERate)); Usb_write_byte(LSB3(line_coding.dwDTERate)); Usb_write_byte(line_coding.bCharFormat); Usb_write_byte(line_coding.bParityType); Usb_write_byte(line_coding.bDataBits); Usb_send_control_in(); while(!(Is_usb_read_control_enabled())); //Usb_clear_tx_complete(); while(!Is_usb_receive_out()); Usb_ack_receive_out(); }
void cdc_get_line_coding(void) { Usb_ack_setup_received_free(); Usb_reset_endpoint_fifo_access(EP_CONTROL); Usb_write_endpoint_data(EP_CONTROL, 8, LSB0(line_coding.dwDTERate)); Usb_write_endpoint_data(EP_CONTROL, 8, LSB1(line_coding.dwDTERate)); Usb_write_endpoint_data(EP_CONTROL, 8, LSB2(line_coding.dwDTERate)); Usb_write_endpoint_data(EP_CONTROL, 8, LSB3(line_coding.dwDTERate)); Usb_write_endpoint_data(EP_CONTROL, 8, line_coding.bCharFormat); Usb_write_endpoint_data(EP_CONTROL, 8, line_coding.bParityType); Usb_write_endpoint_data(EP_CONTROL, 8, line_coding.bDataBits ); Usb_ack_control_in_ready_send(); while (!Is_usb_control_in_ready()); while(!Is_usb_control_out_received()); Usb_ack_control_out_received_free(); }