MAXREFDES63# Code Documentation  V01.00
8-Channel Digital Output MicroPLC
 All Files Functions Variables Macros Pages
max14900e.c
Go to the documentation of this file.
1 
34 /*
35 * Copyright (C) 2012 Maxim Integrated Products, Inc., All Rights Reserved.
36 *
37 * Permission is hereby granted, free of charge, to any person obtaining a
38 * copy of this software and associated documentation files (the "Software"),
39 * to deal in the Software without reps_striction, including without limitation
40 * the rights to use, copy, modify, merge, publish, dips_stribute, sublicense,
41 * and/or sell copies of the Software, and to permit persons to whom the
42 * Software is furnished to do so, subject to the following conditions:
43 *
44 * The above copyright notice and this permission notice shall be included
45 * in all copies or substantial portions of the Software.
46 *
47 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
48 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
49 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
50 * IN NO EVENT SHALL MAXIM INTEGRATED PRODUCTS BE LIABLE FOR ANY CLAIM, DAMAGES
51 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
52 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
53 * OTHER DEALINGS IN THE SOFTWARE.
54 *
55 * Except as contained in this notice, the name of Maxim Integrated Products
56 * shall not be used except as stated in the Maxim Integrated Products
57 * Branding Policy.
58 *
59 * The mere transfer of this software does not imply any licenses
60 * of trade secrets, proprietary technology, copyrights, patents,
61 * trademarks, maskwork rights, or any other form of intellectual
62 * property whatsoever. Maxim Integrated Products retains all ownership rights.
63 *
64 ***************************************************************************/
65 
66 #include "max14900e.h"
67 #include "stm32f10x_gpio.h"
68 #include "stm32f10x_spi.h"
69 
78 {
79  GPIO_SetBits(GPIOB, GPIO_Pin_0); //EN = 1
80  GPIO_SetBits(GPIOB, GPIO_Pin_10); //FLTR = 1
81  GPIO_SetBits(GPIOB, GPIO_Pin_12); //NCS = 1
82  GPIO_ResetBits(GPIOB, GPIO_Pin_11); //CNFG = 0
83 }
84 
85 uint16_t maxim_set_output(uint16_t u_value)
93 {
94  uint16_t u_fault_condition;
95  GPIO_ResetBits(GPIOB, GPIO_Pin_12); //NCS = 0
96  SPI_I2S_SendData(SPI2, u_value);
97  /* Wait for SPI2 data reception */
98  while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET);
99  u_fault_condition=SPI_I2S_ReceiveData(SPI2);
100  GPIO_SetBits(GPIOB, GPIO_Pin_12); //NCS = 1
101  return u_fault_condition;
102 }