Files @ 2a5ab412b8d9
Branch filter:

Location: therm/gpio.c - annotation

Ethan Zonca
Swap out to HAL library and new USB library
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
08c52ee196d1
49b0586d1fdf
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
49b0586d1fdf
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
49b0586d1fdf
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
49b0586d1fdf
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
49b0586d1fdf
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
49b0586d1fdf
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
49b0586d1fdf
8f02a0213d08
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
49b0586d1fdf
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
de0b4c3c6dc2
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
8f02a0213d08
49b0586d1fdf
49b0586d1fdf
49b0586d1fdf
#include "gpio.h"
#include "config.h"

extern volatile uint32_t ticks;

// Increase on each press, and increase at a fast rate after duration elapsed of continuously holding down... somehow...
uint32_t change_time_reset = 0;

void user_input(uint16_t* to_modify)
{
    if(CHANGE_ELAPSED) {
        if(!GPIO_ReadInputDataBit(SW_UP) ) {
            CHANGE_RESET;
            (*to_modify)++;
        }
        else if(!GPIO_ReadInputDataBit(SW_DOWN) && (*to_modify) > 0) {
            CHANGE_RESET;
            (*to_modify)--;
        }
    }
}


void init_gpio(void) {

  GPIO_InitTypeDef GPIO_InitStruct;

    /* GPIO Ports Clock Enable */
  __GPIOF_CLK_ENABLE();
  __GPIOA_CLK_ENABLE();
  __GPIOB_CLK_ENABLE();

   
  //////////////////
  // PORT F       //
  //////////////////  
  
  // PORTF OUTPUT
  // Configure GPIO pin : PF0
  GPIO_InitStruct.Pin = GPIO_PIN_0;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);

  // PORTF UNUSED
  // Configure GPIO pin : PF1
  GPIO_InitStruct.Pin = GPIO_PIN_1;
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);

  
  //////////////////
  // PORT A       //
  //////////////////
  
  // PORT A OUTPUT
  // Configure GPIO pins : PA1 PA2 PA3 PA4
  GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  
  // PORTA INPUT
  // Configure GPIO pin : PA15 
  GPIO_InitStruct.Pin = GPIO_PIN_15;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  // PORTA UNUSED
  // Configure GPIO pins : PA0 PA8
  GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_8;
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  
  // USART1 [PORTA]
  // Configure GPIO pins : PA9 PA10
  GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  GPIO_InitStruct.Alternate = GPIO_AF1_USART1;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  // SPI1 [PORTA]
  // Configure GPIO pin : PA, MOSI, SCK 
  GPIO_InitStruct.GPIO_Pin = GPIO_PIN_7|GPIO_PIN_5;
  GPIO_InitStruct.GPIO_Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.GPIO_PuPd = GPIO_NOPULL;
  GPIO_InitStruct.GPIO_Speed = GPIO_SPEED_HIGH;
  GPIO_InitStruct.Alternate = GPIO_AF1_SPI1;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  
  // Configure GPIO pin: PA, MISO
  GPIO_InitStruct.GPIO_Pin = GPIO_PIN_6;
  GPIO_InitStruct.GPIO_Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.GPIO_PuPd = GPIO_NOPULL;
  GPIO_InitStruct.GPIO_Speed = GPIO_SPEED_HIGH;
  GPIO_InitStruct.Alternate = GPIO_AF1_SPI1;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  // USB [PORTA]

  /** USB GPIO Configuration  
  PA11   ------> USB_DM
  PA12   ------> USB_DP
  */  
  // Configure GPIO pin : PA, D+, D-
  GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11|GPIO_Pin_12;
  GPIO_InitStruct.GPIO_Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;
  GPIO_InitStruct.Alternate = GPIO_AF1_USB;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  
  //////////////////
  // PORT B       //
  //////////////////
  
  // PORT B UNUSED
  // Configure GPIO pins : PB0 PB1 PB8 
  GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_8;
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

  // PORT B INPUT
  // Configure GPIO pins : PB3 PB4 PB5 PB6 PB7
  GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6 
                          |GPIO_PIN_7;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);  
  
  
  // Enable DMA clocks (Is AHB even the right thing???)
  //RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); // EMZ TODO get the right ones


}

// vim:softtabstop=4 shiftwidth=4 expandtab