80 lines
1.1 KiB
C
80 lines
1.1 KiB
C
|
// һЩ<D2BB><D0A9><EFBFBD>õġ<C3B5><C4A1><EFBFBD><EFBFBD>õĽӿ<C4BD>
|
|||
|
|
|||
|
/*
|
|||
|
* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>1
|
|||
|
* @reg <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
* @bit <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һbit
|
|||
|
*/
|
|||
|
void reg_set_one_bit(volatile unsigned int *reg, unsigned int bit)
|
|||
|
{
|
|||
|
unsigned int temp, mask;
|
|||
|
|
|||
|
mask = 1 << bit;
|
|||
|
temp = *reg;
|
|||
|
temp |= mask;
|
|||
|
*reg = temp;
|
|||
|
|
|||
|
return ;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/*
|
|||
|
* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @reg <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
* @bit <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һbit
|
|||
|
*/
|
|||
|
void reg_clr_one_bit(volatile unsigned int *reg, unsigned int bit)
|
|||
|
{
|
|||
|
unsigned int temp, mask;
|
|||
|
|
|||
|
mask = 1 << bit;
|
|||
|
temp = *reg;
|
|||
|
temp &= ~mask;
|
|||
|
*reg = temp;
|
|||
|
|
|||
|
return ;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/*
|
|||
|
* <EFBFBD><EFBFBD>ȡָ<EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>ֵ
|
|||
|
* @reg <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
* @bit <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ȡֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һbit
|
|||
|
* @ret ָ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>ֵ
|
|||
|
*/
|
|||
|
unsigned int reg_get_bit(volatile unsigned int *reg, unsigned int bit)
|
|||
|
{
|
|||
|
unsigned int temp;
|
|||
|
|
|||
|
temp = *reg;
|
|||
|
temp = (temp >> bit) & 1;
|
|||
|
|
|||
|
return temp;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/*
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>дһ<EFBFBD><EFBFBD>32bit<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @data <EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @addr <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
*/
|
|||
|
void reg_write_32(unsigned int data, volatile unsigned int *addr)
|
|||
|
{
|
|||
|
*addr = data;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/*
|
|||
|
* <EFBFBD>ӼĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>32bit<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @addr <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
* @ret <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
unsigned int reg_read_32(volatile unsigned int *addr)
|
|||
|
{
|
|||
|
return (*addr);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|