This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This gist if for article on Timer3 Output Compare |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This gist is for timer delay |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Set peripheral address as ADC data register */ | |
DMA1_Channel1->CPAR = (uint32_t)&ADC1->DR; | |
/* Set memory address as adc_value buffer */ | |
DMA1_Channel1->CMAR = (uint32_t)adc_value; | |
/* Set number of transfers */ | |
DMA1_Channel1->CNDTR = 2U; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setShadowMatrix(GLfloat *destMat, float *lightPos, double *plane) | |
{ | |
GLfloat dot; | |
// dot product of plane and light position | |
dot = plane[0] * lightPos[0] + plane[1] * lightPos[1] + plane[2] * lightPos[2]; | |
// first column | |
destMat[0] = dot - plane[0] * lightPos[0]; | |
destMat[4] = 0.0f - lightPos[0] * plane[1]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void init_adc(void){ | |
/* Set ADC prescalar*/ | |
RCC->CFGR |= RCC_CFGR_ADCPRE_DIV6; | |
/* Enable clock for ADC & PortA */ | |
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN | RCC_APB2ENR_IOPAEN; | |
/* COnfigure PA0 in analog input mode */ | |
GPIOA->CRL &= ~(GPIO_CRL_CNF0 | GPIO_CRL_MODE0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RCC->CFGR |= RCC_CFGR_PPRE1_2; | |
RCC->CFGR |= RCC_CFGR_PLLXTPRE_HSE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// enable circular mode | |
DMA1_Channel4->CCR |= DMA_CCR_CIRC; | |
// enable interrpt after full transfer | |
DMA1_Channel4->CCR |= DMA_CCR_TCIE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USART() | |
{ | |
if (this == reinterpret_cast<USART *>(USART1)) | |
{ | |
// enable clock for GPIOA and USART1 | |
RCC->APB2ENR |= RCC_APB2ENR_USART1EN | RCC_APB2ENR_IOPAEN; | |
// reset pin configurations for PA9 and PA10 | |
GPIOA->CRH &= ~(GPIO_CRH_MODE10 | GPIO_CRH_MODE9 | GPIO_CRH_CNF10 | GPIO_CRH_CNF9); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swswsw | |
NewerOlder