本文整理汇总了C++中set_port函数的典型用法代码示例。如果您正苦于以下问题:C++ set_port函数的具体用法?C++ set_port怎么用?C++ set_port使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_port函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: seromap_setsleep
static void seromap_setsleep(uintptr_t *port, uint8_t mode, uint8_t wakeup)
{
set_port(port[OMAP_UART_EFR], OMAP_EFR_ENHANCED, OMAP_EFR_ENHANCED); // Set enhanced bit
set_port(port[OMAP_UART_IER], OMAP_IER_SLEEP, mode); // Set sleep mode
set_port(port[OMAP_UART_EFR], OMAP_EFR_ENHANCED, 0); // clear enhanced bit
set_port(port[OMAP_UART_SCR], OMAP_SCR_WAKEUPEN, wakeup); // Set wakeup interrupt
}
示例2: seromap_enable
static void seromap_enable(DEV_OMAP *dev, int enable)
{
uintptr_t *port = dev->port;
write_omap(port[OMAP_UART_LCR], 0x80);
if (!enable) {
atomic_set(&dev->pwm_flag, SEROMAP_PWM_PAGED);
// If HW flow control is ON, assert the RTS line
if (dev->tty.c_cflag & IHFLOW)
set_port(port[OMAP_UART_MCR], OMAP_MCR_DTR|OMAP_MCR_RTS, 0);
while (!(read_omap(port[OMAP_UART_LSR]) & OMAP_LSR_TSRE))
;
nanospin_ns(1000000); // pause for 1ms
write_omap(port[OMAP_UART_MDR1], 0x07);
write_omap(port[OMAP_UART_DLL], 0xFF);
write_omap(port[OMAP_UART_DLH], 0xFF);
}
else {
write_omap(port[OMAP_UART_DLL], dev->brd);
write_omap(port[OMAP_UART_DLH], (dev->brd >> 8) & 0xff);
write_omap(port[OMAP_UART_MDR1], 0x00);
// If HW flow control is ON, de-assert the RTS line
if(dev->tty.c_cflag & IHFLOW)
set_port(port[OMAP_UART_MCR], OMAP_MCR_DTR|OMAP_MCR_RTS, OMAP_MCR_DTR|OMAP_MCR_RTS);
// Allow data transmission to resume
atomic_clr(&dev->pwm_flag, SEROMAP_PWM_PAGED);
}
write_omap(port[OMAP_UART_LCR], dev->lcr);
}
示例3: pulse_clock
void pulse_clock()
{
set_port(TCK,0);
set_port(TCK,1);
_delay_us(1000);
#ifdef DEBUG_MODE
// LOG_DEBUG("M=%d I=%d",(out_word&TMS)?1:0,(out_word&TDI)?1:0);
#endif
set_port(TCK,0);
}
示例4: delay
/* Wait at least the specified number of microsec. */
void delay(long microsec)
{
// _delay_ms(microsec>>12);
set_port(TCK,0);
while (--microsec > 0) {
set_port(TCK,1);
_delay_us(1);
set_port(TCK,0);
_delay_us(1);
}
}
示例5: natt_float_ports
int
natt_float_ports(struct sockaddr *remote, struct sockaddr *local, uint16_t port)
{
if (!set_port(remote, port)) {
return -1;
}
if (!set_port(local, port)) {
return -1;
}
return 0;
}
示例6: main
int main(int argc,char* argv[])
{
int port_fd;
int len;
char recv_buf[9];
int i;
if(argc!=3){
printf("Usage: %s /dev/ttySn 0(send data)/1(receive data)\n",argv[0]);
return -1;
}
port_fd=open_port(argv[1]);
if(port_fd==-1){
printf("Program Exit\n");
return -1;
}
//设置串口通信参数
struct port_info info;
info.baud_rate=9600;
info.data_bits=8;
info.flow_ctrl=2;
info.port_fd=port_fd;
info.stop_bit=1;
info.parity=0;
if(set_port(&info)==-1){
printf("Program Exit\n");
return -1;
}
if(strcmp(argv[2],"0")==0){
for(i=0;i<10;i++){
len=send_data(port_fd,"Test Data",9);
if(len>0)
printf("%d send data successfully\n",i);
else
printf("send data failed\n");
sleep(2);
}
close_port(port_fd);
}else{
while(1){
len=recv_data(port_fd,recv_buf,9);
if(len>0){
for(i=0;i<len;i++)
printf("receive data is %s\n",recv_buf);
}else
printf("cannot receive data\n");
sleep(2);
}
}
return 0;
}
示例7: main
int main(void) {
init();
// set port to initial state depending on ACO
set_port();
// reset ACIF to not to trigger interrupt immediately after sei
#ifdef PROC_at90s4433
ACSR = _BV(AINBG) | _BV(ACIE) | _BV(ACI);
#else
#ifdef PROC_at90s8515
ACSR = _BV(ACIE) | _BV(ACI);
#else
ACSR = _BV(ACBG) | _BV(ACIE) | _BV(ACI);
#endif
#endif
// enable interrupts
sei();
do {
in_loop = 1;
} while(1); // do forever
}
示例8: main
int main(){
struct addrinfo hints;
struct addrinfo *result;
char port_no[8], server_address[30], buffer[MAX_BUFLEN];
int status;
int socket_fd; // socket file descriptor
log_init(l, "../");
set_port(port_no);
set_server(server_address);
//ensuring hints is empty and calling getaddrinfo()
memset(&hints, 0, sizeof(struct addrinfo));
//filling in hints with required values
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
if((status = getaddrinfo(server_address, port_no, &hints, &result ))!=0){
log_error(errno, gai_strerror(status));
}
if((socket_fd = socket(result->ai_family, result->ai_socktype, result->ai_protocol)) == -1) {
log_error(errno, "Error creating socket to server.");
}
fprintf(l, "%d\n", result->ai_addrlen);
if(connect(socket_fd, result->ai_addr, result->ai_addrlen)==-1){
log_error(errno, "Error connecting!\n");
}
// sending sample data to buffer
strcpy(buffer,"[email protected]");
write(socket_fd, buffer, MAX_BUFLEN);
}
示例9: SetPGDDir
void SetPGDDir(uchar f)
{
#if 0
int dirb = (1<<PGC) | (1<<PGM) | (1<<MCLR);
if(f) dirb |= (1<<PGD);
set_port(Ddrb ,dirb);
#else
// PIC
if(f) {
dirPGD=0; // out
}else{
dirPGD=1; // in
}
/* int dirc = (1<<PGM) | (1<<MCLR);
int dirb = (1<<PGC) ;
if(f) dirb |= (1<<PGD);
set_port(Ddrb ,dirb ^ 0xff);
set_port(Ddrc ,dirc ^ 0xff);
*/
#endif
}
示例10: omap_clock_enable
void
omap_clock_enable(DEV_OMAP* dev, clk_enable_t clk_cfg)
{
int enable_rc = 0;
int functional_rc = 0;
/* Our idle state can be changed by the ISR so we must use a spinlock */
InterruptLock(&dev->idle_spinlock);
/* Only enable clocks if they aren't enabled already */
if (dev->idle == 0) {
goto done;
}
if (dev->clkctrl_base) {
/* Enable the clock */
out32(dev->clkctrl_base, OMAP_CLKCTRL_MODMODE_ENABLE);
/* Wait for the module mode to have been written */
enable_rc = poll_for_condition(dev->clkctrl_base, OMAP_CLKCTRL_MODMODE_MASK, OMAP_CLKCTRL_MODMODE_ENABLE);
/* Wait for the module idle status to report "fully functional" */
functional_rc = poll_for_condition(dev->clkctrl_base, OMAP_CLKCTRL_IDLEST_MASK, OMAP_CLKCTRL_IDLEST_FUNCTIONAL);
/* Re-configure clock if specified otherwise simply skip it */
if (clk_cfg != clk_enable_skip) {
/* Set the idle mode to smart idle with wake up */
set_port(dev->port[OMAP_UART_SYSC], OMAP_UART_SYSC_IDLEMODE_MASK, clk_cfg);
}
/* Enable the CTS wakeup */
write_omap(dev->port[OMAP_UART_WER], OMAP_UART_WER_CTS_ENABLE);
/* Indicate clocks are enabled */
dev->idle = 0;
}
done:
#ifdef WINBT
/* clear CTS debounce timer and OHW_PAGED flag */
if (dev->tty.un.s.spare_tmr > 0) {
dev->tty.un.s.spare_tmr = 0;
if (dev->tty.flags & OHW_PAGED)
atomic_clr (&dev->tty.flags, OHW_PAGED);
}
#endif
omap_uart_ctx_restore(dev);
InterruptUnlock(&dev->idle_spinlock);
/* Don't slog while interrupts are disabled - otherwise slogf() will re-enable interrupts */
if (enable_rc) {
slogf(_SLOG_SETCODE(_SLOGC_CHAR, 0), _SLOG_ERROR, "%s: Failed to set module mode to 'enabled'", __FUNCTION__);
}
if (functional_rc) {
slogf(_SLOG_SETCODE(_SLOGC_CHAR, 0), _SLOG_ERROR, "%s: Module failed to report 'fully functional'", __FUNCTION__);
}
}
示例11: bufferOverflow
/**************************************************************************
* to be called if memory full (out of buffers)
*
* It will write the code 253 to the trace.
* It will morse code "MEM".
* It will then turn on two LEDs (color=purple + led2) and then halt.
**************************************************************************/
void bufferOverflow(void)
{
TRACE(253);
beeps("-- . --");
pri_rgb_led_on(true, false, true);
set_port(LED1);
sleep_mode();
}
示例12: clear_device
static void
clear_device(const uintptr_t *port)
{
write_omap(port[OMAP_UART_IER], 0); // Disable all interrupts
/* Clear FIFOs */
set_port(port[OMAP_UART_FCR], OMAP_FCR_RXCLR | OMAP_FCR_TXCLR, OMAP_FCR_RXCLR | OMAP_FCR_TXCLR);
read_omap(port[OMAP_UART_LSR]); // Clear Line Status Interrupt
read_omap(port[OMAP_UART_MSR]); // Clear Modem Interrupt
}
示例13: server_sock
/**
* ソケット接続
*
* @return ソケット
*/
int
server_sock(void)
{
struct sockaddr_in addr; /* ソケットアドレス情報構造体 */
int retval = 0; /* 戻り値 */
int optval = 0; /* オプション */
int sock = -1; /* ソケット */
dbglog("start");
/* 初期化 */
(void)memset(&addr, 0, sizeof(struct sockaddr_in));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
/* ポート番号またはサービス名を設定 */
if (set_port(&addr, portno) < 0)
return EX_NG;
/* ソケット生成 */
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
outlog("sock=%d", sock);
return EX_NG;
}
/* ソケットオプション */
optval = 1; /* 二値オプション有効 */
retval = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &optval,
(socklen_t)sizeof(int));
if (retval < 0) {
outlog("setsockopt=%d, sock=%d", retval, sock);
goto error_handler;
}
/* ソケットにアドレスを指定 */
retval = bind(sock, (struct sockaddr *)&addr, (socklen_t)sizeof(addr));
if (retval < 0) {
if (errno == EADDRINUSE)
(void)fprintf(stderr, "Address already in use\n");
outlog("bind=%d, sock=%d", retval, sock);
goto error_handler;
}
/* アクセスバックログの指定 */
retval = listen(sock, SOMAXCONN);
if (retval < 0) {
outlog("listen=%d, sock=%d", retval, sock);
goto error_handler;
}
return sock;
error_handler:
close_sock(&sock);
return EX_NG;
}
示例14: init_package_head
void init_package_head(ap_package_t *pkt, U8 data_type,U8 src_addr, U8 dst_addr, U8 port, U8 ttl, U8 type)
{
memset(pkt, 0, sizeof(ap_package_t));
set_src_addr(pkt, src_addr);
set_dst_addr(pkt, dst_addr);
set_port(pkt, port);
set_ttl(pkt, ttl);//赋值为7
set_type(pkt, type);//type传入参数为0
set_CoS(pkt,data_type);
}
示例15: serial_init
void serial_init(){
if((fd_serial = open_serialport(serialPort)) == -1){
perror("Open port");
return -1;
}
if( set_port(fd_serial,serialspeed,8,'N',1) == -1){
perror("Set_Port");
return -1;
}
}