STM32 a nastavení lock-bitu pres OpenOCD
Jaroslav Buchta
jaroslav.buchta na hascomp.cz
Středa Listopad 5 20:22:47 CET 2014
Mozna, no, ale kdyz pouziju tu funkci, nemusim to resit ;-)
Me prece jen napr. takovyto zapis prijde dost prehledny a elegantni, po
prekladu a optimalizaci to neni ani nejak neefektivni.>
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
DMA_InitTypeDef DMA_InitStructure;
DMA_StructInit(&DMA_InitStructure);
/* USART1_Rx_DMA_Channel (triggered by USART1 Rx event) Config */
DMA_DeInit(DMA1_Channel5);
DMA_InitStructure.DMA_PeripheralBaseAddr =
(uint32_t)&(USART1->DR); //USART1 DR
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)mstRcvBuf;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize = MSTRCVBUFLEN;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel5, &DMA_InitStructure);
DMA_StructInit(&DMA_InitStructure);
/* USART1_Tx_DMA_Channel (triggered by USART1 Tx event) Config */
DMA_DeInit(DMA1_Channel4);
DMA_InitStructure.DMA_PeripheralBaseAddr =
(uint32_t)&(USART1->DR); //USART1 DR
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)bufTxMaster;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_Medium;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel4, &DMA_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 14;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
DMA_ITConfig(DMA1_Channel5, DMA_IT_HT| DMA_IT_TC, ENABLE);
/* Enable USART1 DMA RX request */
USART_DMACmd(USART1, USART_DMAReq_Rx, ENABLE);
/* Enable USART1 DMA TX request */
USART_DMACmd(USART1, USART_DMAReq_Tx, ENABLE);
DMA_Cmd(DMA1_Channel5, ENABLE);
Dne 5. 11. 2014 19:53, Jan Waclawek napsal(a):
>> Treba inicializace DMA je podstatne jednodussi naplnenim cca 15 polozek
>> struktury dle nejakeho vzoroveho prikladu a pouzitim funkce ...Init, nez
>> hledanim jake registry jak nastavit a v jakem poradi...
> Zhodou okolnosti su to len 4 registre - zdojova adresa, cielova adresa,
> pocet prenasanych poloziek a riadiaci register (plus treba vynulovat
> status bity, t.j. spolu s tym je to 5) a v lubovolnom poradi, kym sa to
> DMA nepovoli (tj najjednoduchsie je zapisovat do kontrolneho nakoniec,
> inak je to jedno).
>
> S pozitim symbolov z stm32xxxx.h je to aj prehladne (akurat si treba
> dopisat definicie poloziek pre bitove polia, KTORE BY SOM AJ NA TOMTO
> MIESTE RAD POPROSIL OD PRITOMNYCH Z ST, ABY ICH DOPLNILI), napr.
> www.efton.sk/STM32/bt.c spolu s www.efton.sk/STM32/stm32f4xx.h.zip
>
> wek
>
>
> _______________________________________________
> HW-list mailing list - sponsored by www.HW.cz
> Hw-list na list.hw.cz
> http://list.hw.cz/mailman/listinfo/hw-list
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
Další informace o konferenci Hw-list