⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 set_channel.c

📁 uboot底层驱动
💻 C
字号:
//#include <stdlib.h>#include "my_printf.h"#include "set_channel.h"#include "erase_copy.h"#include "uart.h"#define START 0x200f2000float rvalue;typedef struct  {	   double					  IA,//		  IB,//		  IC,//		  I0,//		  		  UA,//		 		  UB,//				  UC;//} Channel_Adjust;Channel_Adjust adjust;extern void atoff(char *);/*void adjust_save(void){	int size, i;	unsigned short temp, j;	size = sizeof(adjust);	NorFlash_unlock(START);	NorFlash_bolckerase(START);	for(i=0;i<size;i++, i++)	{   	    temp =  *(volatile unsigned short *)( &adjust + i*2 );		NorFlash_write( (START + i), temp );    		}    	if( (check((U32)&adjust, START, size)) != 1)		my_printf("burning error!\n\r");	else my_printf("Everything is OK now!!\n");}*/void adjust_save(void){	int size, i;	unsigned  j;	unsigned short temp;	size = sizeof(adjust);	NorFlash_unlock(START );	NorFlash_bolckerase(START);	j =(unsigned) (unsigned short *)(&adjust);	for(i=0;i<size;i++, i++)	{  	     	    // my_printf("the addr 0x%x\n\r",  i+j);			    temp =   *(volatile unsigned short *)(j + i );		NorFlash_write( (START + i), temp );    		}    	if( (check((U32)&adjust, 0x200f2000, size)) != 1)		my_printf("burning error!\n\r");	else my_printf("Saving is OK now!!\n");}	intset_channel(void){	char cmd[20], value[20], chh;	int i;		adjust.IA = 1;	adjust.IB = 1;	adjust.IC = 1;	adjust.I0 = 1;	adjust.UA = 1;	adjust.UB = 1;	adjust.UC = 1;	my_printf("the addr is 0x%x\n\r", &adjust);	my_printf("size of struct%d\n\r", sizeof(adjust));	//adjust_save();	do {		i = 0;		//my_printf("choose:", c);		my_printf("(1)set_Ia(2)set_Ib(3)set_Ic(4)set_I0(5)set_Ua(6)set_Ub(7)set_Uc(8)save(0)exit\n\r");		my_printf("choose:");		do {			uart_getchar(UART0_BASE, &chh );			cmd[i++] = chh;			uart_putchar( UART0_BASE, chh );		} while (chh != '\r');		cmd[i-1] = '\0';		if ( cmd[0] == '0' ) return 0;		if ( cmd[0] == '8' ) 		{		  adjust_save(); 		  return 0;		}		my_printf("\ninput double value:");		i = 0;		do {			uart_getchar(UART0_BASE, &chh );			value[i++] = chh;			uart_putchar( UART0_BASE, chh );		} while (chh != '\r');		value[i-1] = '\0';		my_printf("value is %s\n\r", value);		//rvalue = strtod(value,(char **) NULL);	    atoff(value);		switch( cmd[0] ) { 				case '1':				adjust.IA = rvalue;				break;				case '2':				adjust.IB = rvalue;				break;				case '3':				adjust.IC = rvalue;				break;				case '4':				adjust.I0 = rvalue;				break;				case '5':				adjust.UA = rvalue;				break;				case '6':				adjust.UB= rvalue;				break;				case '7':				adjust.UC = rvalue;				break;				case '8':				break;				case '0':				break;				default:				my_printf("error cmd\r");				break;		}		my_printf("\n");	} while (1);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -