質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.51%
C

C言語は、1972年にAT&Tベル研究所の、デニス・リッチーが主体となって作成したプログラミング言語です。 B言語の後継言語として開発されたことからC言語と命名。そのため、表記法などはB言語やALGOLに近いとされています。 Cの拡張版であるC++言語とともに、現在世界中でもっとも普及されているプログラミング言語です。

Atmel Studio

Atmel Studioは、マイクロチップ・テクノロジー社が製造しているマイコンであるAVRやSAMのプログラミングを容易にするための統合開発環境です。同社が無料で提供しており、以前はAVR Studioと呼ばれていました。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

Q&A

解決済

1回答

1823閲覧

CdSセルを使ってLEDライトの明るさを制御するコードのエラー

退会済みユーザー

退会済みユーザー

総合スコア0

C

C言語は、1972年にAT&Tベル研究所の、デニス・リッチーが主体となって作成したプログラミング言語です。 B言語の後継言語として開発されたことからC言語と命名。そのため、表記法などはB言語やALGOLに近いとされています。 Cの拡張版であるC++言語とともに、現在世界中でもっとも普及されているプログラミング言語です。

Atmel Studio

Atmel Studioは、マイクロチップ・テクノロジー社が製造しているマイコンであるAVRやSAMのプログラミングを容易にするための統合開発環境です。同社が無料で提供しており、以前はAVR Studioと呼ばれていました。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

0グッド

0クリップ

投稿2018/01/11 04:31

編集2018/01/11 05:22

###前提・実現したいこと
AtmelStudioを使ってC言語のコードを書いています。
実装したいこととしては、CdSセルを使ってLEDライトの明るさを制御することです。
マイコンは「ATSAMl21E16B」を使用しています。
以下、コード作成の参考にしているサイトです。

SAM Port (PORT) Driver
Quick Start Guide for PORT - Basic

###発生している問題・エラーメッセージ
以下のようにエラーメッセージが表示されていますが、どのように修正すればいいのかわからず、アドバイスをいただけますと幸いです。

Severity Code Description Project File Line Error recipe for target 'src/main.o' failed trial C:\Users\rg\Documents\Atmel Studio\7.0\trial\trial\Debug\Makefile 332 Severity Code Description Project File Line Error implicit declaration of function 'configure_adc' [-Werror=implicit-function-declaration] trial C:\Users\rg\Documents\Atmel Studio\7.0\trial\trial\src\main.c 47

1つめのエラーが指している場所はmain.cとは別の場所にあったため、以下明記します。

src/%.o: ../src/%.c @echo Building file: $< @echo Invoking: ARM/GNU C Compiler : 6.3.1 $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAML21E16B__ -DDEBUG -DBOARD=USER_BOARD -DARM_MATH_CM0PLUS=true -DADC_CALLBACK_MODE=true -DUSART_CALLBACK_MODE=true -I"../src/ASF/common/boards" -I"../src/ASF/sam0/utils" -I"../src/ASF/sam0/utils/header_files" -I"../src/ASF/sam0/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/common/utils" -I"../src/ASF/sam0/utils/cmsis/saml21/include_b" -I"../src/ASF/sam0/utils/cmsis/saml21/source" -I"../src/ASF/sam0/drivers/system" -I"../src/ASF/sam0/drivers/system/clock/clock_saml21" -I"../src/ASF/sam0/drivers/system/clock" -I"../src/ASF/sam0/drivers/system/interrupt" -I"../src/ASF/sam0/drivers/system/interrupt/system_interrupt_saml21" -I"../src/ASF/sam0/drivers/system/pinmux" -I"../src/ASF/sam0/drivers/system/power/power_sam_l" -I"../src/ASF/sam0/drivers/system/power" -I"../src/ASF/sam0/drivers/system/reset/reset_sam_l" -I"../src/ASF/sam0/drivers/system/reset" -I"../src/ASF/common2/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/common/services/serial" -I"../src/ASF/sam0/drivers/adc" -I"../src/ASF/sam0/drivers/adc/adc_sam_l_c" -I"../src/ASF/sam0/drivers/sercom" -I"../src/ASF/sam0/drivers/sercom/usart" -O1 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m0plus -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" @echo Finished building: $<

###該当のソースコード

c

1#include <asf.h> 2#include <stdint.h> 3#include <stdlib.h> 4//#define unit16_t unsigned short int 5struct adc_module adc_instance; 6struct usart_module usart_instance; 7 8void configure_usart(void){ 9 struct usart_config config_usart; 10 usart_get_config_defaults(&config_usart); 11 config_usart.mux_setting = USART_RX_1_TX_2_XCK_3; 12 config_usart.pinmux_pad0 = SERCOM2_PAD0_DEFAULT; //check this these corresponding to PA8, 9, 10, 11 13 config_usart.pinmux_pad1 = SERCOM2_PAD1_DEFAULT; 14 config_usart.pinmux_pad2 = SERCOM2_PAD2_DEFAULT; 15 config_usart.pinmux_pad3 = SERCOM2_PAD3_DEFAULT; 16 while (usart_init(&usart_instance, SERCOM2, &config_usart) != STATUS_OK){} 17 usart_enable(&usart_instance); 18} 19 20void configure_adv(void){ 21 struct adc_config config_adc; 22 23 adc_get_config_defaults(&config_adc); 24 config_adc.reference = ADC_REFCTRL_REFSEL_INTVCC2; 25 adc_init(&adc_instance, ADC, &config_adc); 26 adc_enable(&adc_instance); 27} 28 29int main (void) 30{ 31 system_init(); 32 //struct system_standby_config st; 33 //st.power_domain = SYSTEM_POWER_DOMAIN_PD01; 34 struct system_pinmux_config config_pinmux; 35 system_pinmux_get_config_defaults(&config_pinmux); 36 37 config_pinmux.mux_position = 1; //ADC. please see page 540 of the spec sheet 38 system_pinmux_pin_set_config(2, &config_pinmux); //pin number is starting from zero, sp this is pad3 39 system_pinmux_pin_set_config(3, &config_pinmux); // this is pad4 40 config_pinmux.mux_position = 3; //USARcom because of the chosen pins this has to be mux 0 41 system_pinmux_pin_set_config(10, &config_pinmux); //pin11 42 system_pinmux_pin_set_config(11, &config_pinmux); //pin 12 RX 43 system_pinmux_pin_set_config(12, &config_pinmux); //pin 13 TX 44 system_pinmux_pin_set_config(13, &config_pinmux); //pin 14 Clock 45 46 //system_interrupt_enable_global(); 47 configure_adc(); 48 configure_usart(); 49 uint8_t string[] = "Hello World\r\n"; 50 51 usart_write_buffer_wait(&usart_instance, string, sizeof(string)); 52 uint16_t temp; 53 while (true){ 54 if(usart_read_wait(&usart_instance, &temp)==STATUS_OK){ 55 while(usart_write_wait(&usart_instance, temp)!=STATUS_OK){ 56 57 } 58 } 59} 60adc_start_conversion(&adc_instance); 61uint16_t result, ans; 62 63do{ 64 65}while(adc_read(&adc_instance, &result) == STATUS_BUSY); 66ans = result; //eliminate the optimization to see the result 67 68 /* Insert application code here. after the board has been initializae. */ 69}

###試したこと
Lチカは以下のコードで行うことができました。
Lチカのコード

C

1/** 2 * \file 3 * 4 * \brief Empty user application template 5 * 6 */ 7/** 8 * \mainpage User Application template doxygen documentation 9 * 10 * \par Empty user application template 11 * 12 * Bare minimum empty user application template 13 * 14 * \par Content 15 * 16 * -# Include the ASF header files (through asf.h) 17 * -# Minimal main function that starts with a call to system_init() 18 * -# "Insert application code here" comment 19 * 20 */ 21/* 22 * Include header files for all drivers that have been imported from 23 * Atmel Software Framework (ASF). 24 */ 25/* 26 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a> 27 */ 28#include <asf.h> 29#define LED_0_PIN 16 30 31void configure_port_pins(void); 32int main (void) 33{ 34 system_init(); 35 configure_port_pins(); 36 /* Insert application code here, after the board has been initialized. */ 37 while (true) { 38 bool pin_state = 1; 39 port_pin_set_output_level(LED_0_PIN, pin_state); 40 } 41} 42void configure_port_pins(void) 43{ 44 struct port_config config_port_pin; 45 port_get_config_defaults(&config_port_pin); 46 config_port_pin.direction = PORT_PIN_DIR_OUTPUT; 47 port_pin_set_config(LED_0_PIN, &config_port_pin); 48} 49

###補足情報(言語/FW/ツール等のバージョンなど)
回路では2ピンにCdSセルが、16ピンにLEDライトが繋がっています。
Atmel Studio 7.0

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ozwk

2018/01/11 04:35

エラー読んでますか?
退会済みユーザー

退会済みユーザー

2018/01/11 05:55 編集

読んでいますが、理解が難しい状態です。
ozwk

2018/01/11 05:58

implicit declaration of function 'configure_adc'についても?
退会済みユーザー

退会済みユーザー

2018/01/11 06:24 編集

はい、検索してもわかりません。
guest

回答1

0

ベストアンサー

2つ目のエラーは「configure_adc」が見つからないというエラーでしょう。
「configure_adv」というルーチンはあるので単なるタイプミスかと思います。

投稿2018/01/11 08:01

PineMatsu

総合スコア3579

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2018/01/11 10:03

ご回答いただきましてありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.51%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問