". Net Micro Framework portingkit–09" serial Driver

Source: Internet
Author: User
Tags volatile

Although in the PC machine, the serial line is becoming far away, but in the embedded field, the serial port can still be said to be the zenith, because it is inexpensive, and programming is also more convenient, in no display or input equipment system, serial port is indispensable, and HyperTerminal together to solve the information display and input problems.

After these days of efforts, the CORTEX-M3 platform of the. Net Micro framework of the Nativesample porting work will be a paragraph, currently implemented boot code, SRAM, Clock (RCC), Interrupt (NVIC), Systick, GPIO , serial port, Nandflash (FMSC) and other related functions, these codes can be said to make tinyclr normal work of the smallest set, with these work to pave the next can be transplanted tinyclr, if we use the CORTEX-M3 Development Board has more than 2M of RAM, Then our work to this step may be completed 90%, but due to limited resources, the next debugging must be Flash version, so the unknown work will be many, and debugging will become difficult, no matter how our. Net Micro Framework Portingkit Tour will continue, but, to say the truth, from scratch to complete these work, although arduous, but harvest quite abundant, to arm development (especially cortex-m3) understanding is on a level.

OK, let's talk about the development of serial port driver.

As with Gpio development, we still need to write serial port-related register code in CortexM3.h.

struct Cortexm3_usart


{


static const UINT32 c_max_baudrate = 45000000;


static const UINT32 c_min_baudrate = 1200;





static const UINT32 C_BASE1 = 0x40013800;


static const UINT32 C_BASE2 = 0x40004400;


static const UINT32 C_BASE3 = 0x40004800;





/****/volatile UINT16 SR;


Static const UINT16 sr_txe= ((UINT16) 0x0080);


Static const UINT16 sr_tc= ((UINT16) 0x0040);


Static const UINT16 sr_rxne= ((UINT16) 0x0020);





UINT16 RESERVED0;


/****/volatile UINT16 DR;


UINT16 RESERVED1;


/****/volatile UINT16 BRR;


UINT16 RESERVED2;


/****/volatile UINT16 CR1;


static const UINT16 Cr1_ue_set = ((UINT16) 0x2000); USART Enable Mask


static const UINT16 Cr1_ue_reset = ((UINT16) 0xDFFF); USART Disable Mask


static const UINT16 Cr1_parity_no = ((UINT16) 0x0000);


static const UINT16 Cr1_parity_even = ((UINT16) 0x0400);


static const UINT16 cr1_parity_odd = ((UINT16) 0x0600);


static const UINT16 Cr1_databit_8 = ((UINT16) 0x0000);


static const UINT16 Cr1_databit_9 = ((UINT16) 0x1000);


static const UINT16 CR1_MODE_RX = ((UINT16) 0x0004);


static const UINT16 CR1_MODE_TX = ((UINT16) 0x0008);


static const UINT16 Cr1_clear_mask = ((UINT16) 0xe9f3);


static const UINT16 Cr1_peie = ((UINT16) 0x0100);


static const UINT16 Cr1_txeie = ((UINT16) 0x0080);


static const UINT16 Cr1_tcie = ((UINT16) 0x0040);


static const UINT16 Cr1_rxneie = ((UINT16) 0x0020);





UINT16 RESERVED3;


/****/volatile UINT16 CR2;


static const UINT16 Cr2_stopbits_1 = ((UINT16) 0x0000);


static const UINT16 Cr2_stopbits_0_5 = ((UINT16) 0x1000);


static const UINT16 cr2_stopbits_2 = ((UINT16) 0x2000);


static const UINT16 cr2_stopbits_1_5 = ((UINT16) 0x3000);


static const UINT16 cr2_stopbits_mask= ((UINT16) 0xCFFF); /* USART CR2 STOP Bits Mask * *





UINT16 RESERVED4;


/****/volatile UINT16 CR3;


static const UINT16 Cr3_hardwareflowcontrol_none = ((UINT16) 0x0000);


static const UINT16 Cr3_hardwareflowcontrol_rts = ((UINT16) 0x0100);


static const UINT16 cr3_hardwareflowcontrol_cts = ((UINT16) 0x0200);


static const UINT16 cr3_hardwareflowcontrol_rts_cts = ((UINT16) 0x0300);


static const UINT16 Cr3_hardwareflowcontrol_mask = ((UINT16) 0xFCFF);





UINT16 RESERVED5;


/****/volatile UINT16 GTPR;


UINT16 RESERVED6;


};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.