0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

stm32f4-discoveryの作法 その13

Posted at

概要

stm32f4-discoveryの作法、調べてみた。
俺言語を移植してみた。

写真

image

サンプルコード

arduino用を移植。以下、変更点。

uint8_t rx_buffer[20];
void putchr(char c)
{
	char * p = "a";
	p = &c;
	uart_2_send(p, 1);
}
char getch()
{
	if (uart_2_is_interupt()) 
	{
		uart_2_clear_interupt();
		int length = uart_2_get(rx_buffer);
		return rx_buffer[0];
	}
	return;
}
void putint(uint8_t c)
{
	char s;
	char t;
	char * p = "a";
	p = &t;
	uart_2_send(p, 1);
	s = c / 100;
	if (s > 0)
	{
		t = s + 48;
		uart_2_send(p, 1);
		c = c - s * 100;
	}
	s = c / 10;
	if (s > 0)
	{
		t = s + 48;
		uart_2_send(p, 1);
		c = c - s * 10;
	}
	t = c + 48;
	uart_2_send(p, 1);
}
void setup()
{
	for (i = 0; i < MEMSIZE; i++)
	{
		WR(i, '\0');
	}
	WR(Bnd, Obj);
	putstr("\r\nore stm32f4\r\n");
}
int main(void)
{
	driver_init();
	setup();
	while(1)
	{
		char c = getch();
		if (c != NULL) onKey(c);
	}
	return 0;
}

配線

TX  PA2
RX  PA3

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?