|
带PA的使能源码部分不对呀感觉注释了这么多,为什么和官方的不太一样?
void dwt_enable_pa(void)
{
// uint8 buf[4];
// // Set up MFIO for LED output
// dwt_readfromdevice(GPIO_CTRL_ID,0x00,4,buf);
// //enable PA
// buf[1] &= ~0xC0; //clear the bits
// buf[1] |= 0x40;
//
// //EXTTXE
// buf[2] &=~0x03;
// buf[2] |= 0x01;
//
// //EXTTXE
// buf[2] &=~0x0C;
// buf[2] |= 0x04;
//
// dwt_writetodevice(GPIO_CTRL_ID,0x00,4,&buf[0]);
// // //if an external power amplifier is being used, TX fine grain power dequeencing must be disabled
//// dwSpiWrite(dev, PMSC, PMSC_TXFSEQ, 0x0000, LEN_PMSC_TXFSEQ);
// buf[0] = 0;
// buf[1] = 0;
// dwt_writetodevice(PMSC_ID,PMSC_TXFINESEQ_OFFSET,2,&buf[0]);
//uint32 reg;
//// Set up GPIO
//reg = dwt_read32bitreg(GPIO_CTRL_ID); // read the current GPIO_CTRL_ID register
//reg |= 0x00054000; // set the appropriate GPIOs
//dwt_write32bitreg(GPIO_CTRL_ID,reg); // write the modified value back
////disable fine grain sequencing
//dwt_write16bitoffsetreg(PMSC_ID,PMSC_RES3_OFFSET+2,0);
uint32 reg;
// Set up GPIO
reg = dwt_read32bitreg(GPIO_CTRL_ID); // read the current GPIO_CTRL_ID register
reg |= 0x00054000; // set the appropriate GPIOs
// reg |= 0x00014000;
dwt_write32bitreg(GPIO_CTRL_ID,reg); // write the modified value back
//disable fine grain sequencing
dwt_write16bitoffsetreg(PMSC_ID,PMSC_RES3_OFFSET+2,0);
} // end _dwt_enableleds()
/*官方提供*/
void dwt_setlnapamode(int lna, int pa)
{
uint32 gpio_mode = dwt_read32bitoffsetreg(GPIO_CTRL_ID, GPIO_MODE_OFFSET);
gpio_mode &= ~(GPIO_MSGP4_MASK | GPIO_MSGP5_MASK | GPIO_MSGP6_MASK);
if (lna)
{
gpio_mode |= GPIO_PIN6_EXTRXE;
}
if (pa)
{
gpio_mode |= (GPIO_PIN5_EXTTXE | GPIO_PIN4_EXTPA);
}
dwt_write32bitoffsetreg(GPIO_CTRL_ID, GPIO_MODE_OFFSET, gpio_mode);
}
|
|