1 Star 0 Fork 0

ic-starter/up5k

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
cordic.c 702 Bytes
Copy Edit Raw Blame History
#include <stdio.h>
#include <stdint.h>
int main(void)
{
const int bits = 20;
const int max = (1 << bits)/2 - 1; // range is -max to +max
const int shift = 5;
const int shift_mask = (1 << shift) - 1;
int x = max;
int y = 0;
const float k = 1.0;
for(int i = 0 ; i < (1<<21) ; i++)
{
printf("%d %d\n", x, y);
int xp = x + (y >> shift) - (x >> (2*shift+1));
int yp = y - (x >> shift) - (y >> (2*shift+1)); // + (xacc >> shift);
#if 1
if (xp > max)
{
x = max;
y = 0;
} else
if (yp > max)
{
x = 0;
y = max;
} else
if (yp < -max)
{
x = 0;
y = -max;
} else
if (xp < -max)
{
x = -max;
y = 0;
} else
#endif
{
x = xp;
y = yp;
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ic-starter/up5k.git
git@gitee.com:ic-starter/up5k.git
ic-starter
up5k
up5k
master

Search

0d507c66 1850385 C8b1a773 1850385