/*
 * hal_SPI_Flash.h
 *
 *  Created on: Nov 8, 2011
 *      Author: RomanM
 */

#ifndef HAL_SPI_FLASH_H_
#define HAL_SPI_FLASH_H_

#include "stm32f10x.h"

#define hal_SPI_FLASH_SPIx		SPI2

#define	hal_SPI_FLASH_CS_PORT	GPIOC
#define	hal_SPI_FLASH_CS_PIN	GPIO_Pin_4
#define	hal_SPI_FLASH_CS_CLK	RCC_APB2Periph_GPIOC

#define	hal_SPI_FLASH_CS_HIGH()	GPIO_SetBits(hal_SPI_FLASH_CS_PORT, hal_SPI_FLASH_CS_PIN)
#define	hal_SPI_FLASH_CS_LOW()	GPIO_ResetBits(hal_SPI_FLASH_CS_PORT, hal_SPI_FLASH_CS_PIN)

void hal_SPI_Flash_Init(void);
void hal_SPI_Flash_RCC_Config(void);
void hal_SPI_Flash_GPIO_Config(void);

uint8_t hal_SPI_Flash_RW(uint8_t data);
void hal_SPI_Flash_WriteN(uint8_t *outBuff, uint8_t n);
void hal_SPI_Flash_ReadN(uint8_t *inBuff, uint8_t n);

void hal_SPI_Flash_SendAddress(uint32_t address);

#endif /* HAL_SPI_FLASH_H_ */
