GithubHelp home page GithubHelp logo

nds-serial's Introduction

Andes serial module using USART interface

Module description

  • USART break signal should be sent explicitly as RX interrupt event.
  • USART TX and RX can run in parallel.
  • USART-RX line using intterupt mode (non-blocking)
  • USART-TX line using polling mode (blocking)
  • Optional stdout locking mechanism.

main.c

#include "nds-serial/serial.h"
#include <string.h>
#include <stdio.h>

/* external entity */
extern void delay(uint64_t ms);
extern NDS_DRIVER_USART Driver_USART1;

/* private variables */
static char stdin_buffer[512];

/* private function definition */
static void stdin_reader(void *p_buffer, uint16_t u16_cnt)
{
	/* do something with received data */
	/* replace with flag or queue message */
	/* as this is still in interrupt context call */
}

/* public function definition */
int main(void)
{
	uint8_t u8_cntr = 0;

	/* initialize terminal */
	serial_init(&Driver_USART1, 38400, NULL);
	serial_start(stdin_reader, stdin_buffer, sizeof(stdin_buffer));

	/* send directly to serial */
	char* p_text = "hello world\n";
	serial_write(p_text, strlen(p_text));

	/* infinite loop */
	while(1) {
		/* send in-direct using stdout */
		printf("counter = %d\r\n", u8_cntr++);

		delay(1);
	}

	return 0;
}

nds-serial's People

Contributors

pujaerawan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.